Changeset 4994692 in opengl-game for new-game.cpp
- Timestamp:
- Apr 19, 2020, 1:23:02 AM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 5ba732a
- Parents:
- 6385d0f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
new-game.cpp
r6385d0f r4994692 501 501 defineModelGroupAttrib(modelGroups[TYPE_SHIP], "ubo_index", ATTRIB_OBJECT_VARYING, 502 502 1, GL_UNSIGNED_INT, offset_of(&SceneObject::ubo_offset)); 503 /*** END OF REFACTORED CODE ***/504 503 505 504 defineModelGroupUniform(modelGroups[TYPE_SHIP], "view", ATTRIB_UNIFORM, … … 510 509 initModelGroupAttribs(modelGroups[TYPE_SHIP]); 511 510 512 /*** START OF REFACTORED CODE ***/513 511 modelGroups[TYPE_ASTEROID] = createModelGroup( 514 512 loadShaderProgram("gl-shaders/asteroid.vert", "gl-shaders/asteroid.frag")); … … 523 521 defineModelGroupAttrib(modelGroups[TYPE_ASTEROID], "ubo_index", ATTRIB_OBJECT_VARYING, 524 522 1, GL_UNSIGNED_INT, offset_of(&SceneObject::ubo_offset)); 525 /*** END OF REFACTORED CODE ***/526 523 527 524 defineModelGroupUniform(modelGroups[TYPE_ASTEROID], "view", ATTRIB_UNIFORM, … … 532 529 initModelGroupAttribs(modelGroups[TYPE_ASTEROID]); 533 530 534 /*** START OF REFACTORED CODE ***/535 531 modelGroups[TYPE_LASER] = createModelGroup( 536 532 loadShaderProgram("gl-shaders/laser.vert", "gl-shaders/laser.frag")); … … 543 539 defineModelGroupAttrib(modelGroups[TYPE_LASER], "ubo_index", ATTRIB_OBJECT_VARYING, 544 540 1, GL_UNSIGNED_INT, offset_of(&SceneObject::ubo_offset)); 545 /*** END OF REFACTORED CODE ***/546 541 547 542 defineModelGroupUniform(modelGroups[TYPE_LASER], "view", ATTRIB_UNIFORM, … … 553 548 554 549 initModelGroupAttribs(modelGroups[TYPE_LASER]); 555 556 /*** START OF REFACTORED CODE ***/ 550 /*** END OF REFACTORED CODE ***/ 551 557 552 modelGroups[TYPE_EXPLOSION] = createModelGroup( 558 553 loadShaderProgram("gl-shaders/explosion.vert", "gl-shaders/explosion.frag")); … … 565 560 defineModelGroupAttrib(modelGroups[TYPE_EXPLOSION], "ubo_index", ATTRIB_OBJECT_VARYING, 566 561 1, GL_UNSIGNED_INT, offset_of(&SceneObject::ubo_offset)); 567 /*** END OF REFACTORED CODE ***/568 562 569 563 defineModelGroupUniform(modelGroups[TYPE_EXPLOSION], "cur_time", ATTRIB_UNIFORM, … … 829 823 830 824 leftLaser = createLaser( 831 vec3(-0.21f, -1.19f, 1.76f) +offset,832 vec3(-0.21f, -1.19f, -3.0f) +offset,825 vec3(-0.21f, -1.19f, 1.76f) + offset, 826 vec3(-0.21f, -1.19f, -3.0f) + offset, 833 827 vec3(0.0f, 1.0f, 0.0f), 0.03f); 834 828 addObjectToScene(leftLaser, shaderBufferInfo, modelGroups, ubo); … … 1887 1881 // To project point P onto line AB: 1888 1882 // projection = A + dot(AP,AB) / dot(AB,AB) * AB 1889 vec3 projOnLaser = start + glm::dot(cam_pos -start, ray) / (length*length) * ray;1883 vec3 projOnLaser = start + glm::dot(cam_pos - start, ray) / (length * length) * ray; 1890 1884 vec3 laserToCam = cam_pos - projOnLaser; 1891 1885 … … 1944 1938 } 1945 1939 1940 /*** START OF REFACTORED CODE ***/ 1946 1941 void defineModelGroupUniform(ShaderModelGroup& modelGroup, string name, AttribType attribType, 1947 1942 GLint size, UniformType type, GLfloat* data) { … … 1957 1952 1958 1953 void initModelGroupAttribs(ShaderModelGroup& modelGroup) { 1959 /*** START OF REFACTORED CODE ***/1960 1954 glBindVertexArray(modelGroup.vao); 1961 1955 1962 1956 map<string, AttribInfo>::iterator it; 1963 1957 for (it = modelGroup.attribs.begin(); it != modelGroup.attribs.end(); it++) { 1964 /*** END OF REFACTORED CODE ***/1965 1958 if (it->second.attribType == ATTRIB_UNIFORM) { 1966 1959 it->second.buffer = glGetUniformLocation(modelGroup.shaderProgram, it->first.c_str()); 1967 /*** START OF REFACTORED CODE ***/1968 1960 } else { 1969 1961 glEnableVertexAttribArray(it->second.index); … … 1984 1976 } 1985 1977 } 1986 /*** START OF REFACTORED CODE ***/ 1987 } 1978 } 1979 /*** END OF REFACTORED CODE ***/ 1988 1980 1989 1981 void bindUniformData(AttribInfo& attrib) {
Note:
See TracChangeset
for help on using the changeset viewer.