Changeset 5b02676 in opengl-game
- Timestamp:
- Oct 4, 2019, 8:10:09 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 83b5b4b
- Parents:
- ee75487
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
makefile
ree75487 r5b02676 25 25 $(CC) $^ $(DEP) $(CFLAGS) -o $@ 26 26 27 openglgame: main-opengl.cpp opengl-game.cpp crash-logger.cpp logger.cpp game-gui-glfw.cpp imgui_impl_glfw_gl3.cpp $(IMGUI_FILES)27 openglgame: main-opengl.cpp opengl-game.cpp crash-logger.cpp logger.cpp game-gui-glfw.cpp imgui_impl_glfw_gl3.cpp graphics-pipeline_opengl.cpp $(IMGUI_FILES) 28 28 $(CC) $^ $(DEP) $(CFLAGS) -o $@ -DGLEW_STATIC 29 29 … … 59 59 $(CC) $(CXX_FLAGS) -o $@ $^ $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN 60 60 61 vulkangame: main-vulkan.cpp vulkan-game.cpp crash-logger.cpp logger.cpp vulkan-utils.cpp game-gui-sdl.cpp 61 vulkangame: main-vulkan.cpp vulkan-game.cpp crash-logger.cpp logger.cpp vulkan-utils.cpp game-gui-sdl.cpp graphics-pipeline_vulkan.cpp 62 62 $(CC) $(CXX_FLAGS) -o $@ $^ $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN 63 63 -
new-game.cpp
ree75487 r5b02676 166 166 void mouse_button_callback(GLFWwindow* window, int button, int action, int mods); 167 167 void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods); 168 /*** START OF REFACTORED CODE ***/ 168 169 void window_size_callback(GLFWwindow* window, int width, int height); 170 /*** END OF REFACTORED CODE ***/ 169 171 170 172 void APIENTRY debugGlCallback( … … 486 488 map<ObjectType, ShaderModelGroup> modelGroups; 487 489 490 /*** START OF REFACTORED CODE ***/ 488 491 modelGroups[TYPE_SHIP] = createModelGroup( 489 492 loadShaderProgram("gl-shaders/ship.vert", "gl-shaders/ship.frag")); … … 498 501 defineModelGroupAttrib(modelGroups[TYPE_SHIP], "ubo_index", ATTRIB_OBJECT_VARYING, 499 502 1, GL_UNSIGNED_INT, offset_of(&SceneObject::ubo_offset)); 503 /*** END OF REFACTORED CODE ***/ 500 504 501 505 defineModelGroupUniform(modelGroups[TYPE_SHIP], "view", ATTRIB_UNIFORM, … … 506 510 initModelGroupAttribs(modelGroups[TYPE_SHIP]); 507 511 512 /*** START OF REFACTORED CODE ***/ 508 513 modelGroups[TYPE_ASTEROID] = createModelGroup( 509 514 loadShaderProgram("gl-shaders/asteroid.vert", "gl-shaders/asteroid.frag")); … … 518 523 defineModelGroupAttrib(modelGroups[TYPE_ASTEROID], "ubo_index", ATTRIB_OBJECT_VARYING, 519 524 1, GL_UNSIGNED_INT, offset_of(&SceneObject::ubo_offset)); 525 /*** END OF REFACTORED CODE ***/ 520 526 521 527 defineModelGroupUniform(modelGroups[TYPE_ASTEROID], "view", ATTRIB_UNIFORM, … … 526 532 initModelGroupAttribs(modelGroups[TYPE_ASTEROID]); 527 533 534 /*** START OF REFACTORED CODE ***/ 528 535 modelGroups[TYPE_LASER] = createModelGroup( 529 536 loadShaderProgram("gl-shaders/laser.vert", "gl-shaders/laser.frag")); … … 536 543 defineModelGroupAttrib(modelGroups[TYPE_LASER], "ubo_index", ATTRIB_OBJECT_VARYING, 537 544 1, GL_UNSIGNED_INT, offset_of(&SceneObject::ubo_offset)); 545 /*** END OF REFACTORED CODE ***/ 538 546 539 547 defineModelGroupUniform(modelGroups[TYPE_LASER], "view", ATTRIB_UNIFORM, … … 546 554 initModelGroupAttribs(modelGroups[TYPE_LASER]); 547 555 556 /*** START OF REFACTORED CODE ***/ 548 557 modelGroups[TYPE_EXPLOSION] = createModelGroup( 549 558 loadShaderProgram("gl-shaders/explosion.vert", "gl-shaders/explosion.frag")); … … 556 565 defineModelGroupAttrib(modelGroups[TYPE_EXPLOSION], "ubo_index", ATTRIB_OBJECT_VARYING, 557 566 1, GL_UNSIGNED_INT, offset_of(&SceneObject::ubo_offset)); 567 /*** END OF REFACTORED CODE ***/ 558 568 559 569 defineModelGroupUniform(modelGroups[TYPE_EXPLOSION], "cur_time", ATTRIB_UNIFORM, … … 1060 1070 } 1061 1071 1072 /*** START OF REFACTORED CODE ***/ 1062 1073 void window_size_callback(GLFWwindow* window, int width, int height) { 1063 1074 cout << "Window resized to (" << width << ", " << height << ")" << endl; … … 1073 1084 //glfwSetWindowAttrib(window, GLFW_DECORATED, GLFW_FALSE); 1074 1085 } 1086 /*** END OF REFACTORED CODE ***/ 1075 1087 1076 1088 void APIENTRY debugGlCallback( … … 1945 1957 1946 1958 void initModelGroupAttribs(ShaderModelGroup& modelGroup) { 1959 /*** START OF REFACTORED CODE ***/ 1947 1960 glBindVertexArray(modelGroup.vao); 1948 1961 1949 1962 map<string, AttribInfo>::iterator it; 1950 1963 for (it = modelGroup.attribs.begin(); it != modelGroup.attribs.end(); it++) { 1964 /*** END OF REFACTORED CODE ***/ 1951 1965 if (it->second.attribType == ATTRIB_UNIFORM) { 1952 1966 it->second.buffer = glGetUniformLocation(modelGroup.shaderProgram, it->first.c_str()); 1967 /*** START OF REFACTORED CODE ***/ 1953 1968 } else { 1954 1969 glEnableVertexAttribArray(it->second.index); … … 1969 1984 } 1970 1985 } 1986 /*** START OF REFACTORED CODE ***/ 1971 1987 } 1972 1988 -
vulkan-ref.cpp
ree75487 r5b02676 61 61 vector<VkPresentModeKHR> presentModes; 62 62 }; 63 /*** END OF REFACTORED CODE ***/64 63 65 64 struct Vertex { … … 73 72 glm::vec2 texCoord; 74 73 }; 74 /*** END OF REFACTORED CODE ***/ 75 75 76 76 struct UniformBufferObject { … … 174 174 vector<VkImage> swapChainImages; 175 175 VkFormat swapChainImageFormat; 176 VkExtent2D swapChainExtent; 176 /*** END OF REFACTORED CODE ***/ 177 VkExtent2D swapChainExtent; // (This was taken out of vulkan-game for now and replaced with Viewport) 178 /*** START OF REFACTORED CODE ***/ 177 179 vector<VkImageView> swapChainImageViews; 178 180 /*** END OF REFACTORED CODE ***/ … … 369 371 sceneIndices.data(), sizeof(uint16_t), sceneIndices.size()); 370 372 373 /*** START OF REFACTORED CODE ***/ 371 374 addAttributeDescription(scenePipeline, VK_FORMAT_R32G32B32_SFLOAT, offset_of(&Vertex::pos)); 372 375 addAttributeDescription(scenePipeline, VK_FORMAT_R32G32B32_SFLOAT, offset_of(&Vertex::color)); 373 376 addAttributeDescription(scenePipeline, VK_FORMAT_R32G32_SFLOAT, offset_of(&Vertex::texCoord)); 377 /*** END OF REFACTORED CODE ***/ 374 378 375 379 addDescriptorInfo(scenePipeline, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_SHADER_STAGE_VERTEX_BIT, &uniformBufferInfoList, nullptr); … … 394 398 overlayIndices.data(), sizeof(uint16_t), overlayIndices.size()); 395 399 400 /*** START OF REFACTORED CODE ***/ 396 401 addAttributeDescription(overlayPipeline, VK_FORMAT_R32G32B32_SFLOAT, offset_of(&OverlayVertex::pos)); 397 402 addAttributeDescription(overlayPipeline, VK_FORMAT_R32G32_SFLOAT, offset_of(&OverlayVertex::texCoord)); 403 /*** END OF REFACTORED CODE ***/ 398 404 399 405 addDescriptorInfo(overlayPipeline, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr, &overlayImageInfo); … … 809 815 const void* vertexData, int vertexSize, size_t numVertices, 810 816 const void* indexData, int indexSize, size_t numIndices) { 817 /*** START OF REFACTORED CODE ***/ 811 818 // Since there is only one array of vertex data, we use binding = 0 812 819 // I'll probably do that for the foreseeable future … … 816 823 info.bindingDescription.stride = vertexSize; 817 824 info.bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX; 825 /*** END OF REFACTORED CODE ***/ 818 826 819 827 info.numVertices = numVertices; … … 886 894 VkPipelineVertexInputStateCreateInfo vertexInputInfo = {}; 887 895 vertexInputInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; 888 /*** END OF REFACTORED CODE ***/889 896 890 897 vertexInputInfo.vertexBindingDescriptionCount = 1; … … 968 975 pipelineLayoutInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; 969 976 pipelineLayoutInfo.setLayoutCount = 1; 977 /*** END OF REFACTORED CODE ***/ 970 978 pipelineLayoutInfo.pSetLayouts = &info.descriptorSetLayout; 971 979 pipelineLayoutInfo.pushConstantRangeCount = 0;
Note:
See TracChangeset
for help on using the changeset viewer.