Changeset 5b02676 in opengl-game


Ignore:
Timestamp:
Oct 4, 2019, 8:10:09 PM (5 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
83b5b4b
Parents:
ee75487
Message:

Make vulkangame and openglgame compile on OSX with the new GraphicsPipeline classes

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • makefile

    ree75487 r5b02676  
    2525        $(CC) $^ $(DEP) $(CFLAGS) -o $@
    2626
    27 openglgame: main-opengl.cpp opengl-game.cpp crash-logger.cpp logger.cpp game-gui-glfw.cpp imgui_impl_glfw_gl3.cpp $(IMGUI_FILES)
     27openglgame: 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)
    2828        $(CC) $^ $(DEP) $(CFLAGS) -o $@ -DGLEW_STATIC
    2929
     
    5959        $(CC) $(CXX_FLAGS) -o $@ $^ $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN
    6060
    61 vulkangame: main-vulkan.cpp vulkan-game.cpp crash-logger.cpp logger.cpp vulkan-utils.cpp game-gui-sdl.cpp
     61vulkangame: main-vulkan.cpp vulkan-game.cpp crash-logger.cpp logger.cpp vulkan-utils.cpp game-gui-sdl.cpp graphics-pipeline_vulkan.cpp
    6262        $(CC) $(CXX_FLAGS) -o $@ $^ $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN
    6363
  • new-game.cpp

    ree75487 r5b02676  
    166166void mouse_button_callback(GLFWwindow* window, int button, int action, int mods);
    167167void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods);
     168/*** START OF REFACTORED CODE ***/
    168169void window_size_callback(GLFWwindow* window, int width, int height);
     170/*** END OF REFACTORED CODE ***/
    169171
    170172void APIENTRY debugGlCallback(
     
    486488   map<ObjectType, ShaderModelGroup> modelGroups;
    487489
     490/*** START OF REFACTORED CODE ***/
    488491   modelGroups[TYPE_SHIP] = createModelGroup(
    489492      loadShaderProgram("gl-shaders/ship.vert", "gl-shaders/ship.frag"));
     
    498501   defineModelGroupAttrib(modelGroups[TYPE_SHIP], "ubo_index", ATTRIB_OBJECT_VARYING,
    499502      1, GL_UNSIGNED_INT, offset_of(&SceneObject::ubo_offset));
     503/*** END OF REFACTORED CODE ***/
    500504
    501505   defineModelGroupUniform(modelGroups[TYPE_SHIP], "view", ATTRIB_UNIFORM,
     
    506510   initModelGroupAttribs(modelGroups[TYPE_SHIP]);
    507511
     512/*** START OF REFACTORED CODE ***/
    508513   modelGroups[TYPE_ASTEROID] = createModelGroup(
    509514      loadShaderProgram("gl-shaders/asteroid.vert", "gl-shaders/asteroid.frag"));
     
    518523   defineModelGroupAttrib(modelGroups[TYPE_ASTEROID], "ubo_index", ATTRIB_OBJECT_VARYING,
    519524      1, GL_UNSIGNED_INT, offset_of(&SceneObject::ubo_offset));
     525/*** END OF REFACTORED CODE ***/
    520526
    521527   defineModelGroupUniform(modelGroups[TYPE_ASTEROID], "view", ATTRIB_UNIFORM,
     
    526532   initModelGroupAttribs(modelGroups[TYPE_ASTEROID]);
    527533
     534/*** START OF REFACTORED CODE ***/
    528535   modelGroups[TYPE_LASER] = createModelGroup(
    529536      loadShaderProgram("gl-shaders/laser.vert", "gl-shaders/laser.frag"));
     
    536543   defineModelGroupAttrib(modelGroups[TYPE_LASER], "ubo_index", ATTRIB_OBJECT_VARYING,
    537544      1, GL_UNSIGNED_INT, offset_of(&SceneObject::ubo_offset));
     545/*** END OF REFACTORED CODE ***/
    538546
    539547   defineModelGroupUniform(modelGroups[TYPE_LASER], "view", ATTRIB_UNIFORM,
     
    546554   initModelGroupAttribs(modelGroups[TYPE_LASER]);
    547555
     556/*** START OF REFACTORED CODE ***/
    548557   modelGroups[TYPE_EXPLOSION] = createModelGroup(
    549558      loadShaderProgram("gl-shaders/explosion.vert", "gl-shaders/explosion.frag"));
     
    556565   defineModelGroupAttrib(modelGroups[TYPE_EXPLOSION], "ubo_index", ATTRIB_OBJECT_VARYING,
    557566      1, GL_UNSIGNED_INT, offset_of(&SceneObject::ubo_offset));
     567/*** END OF REFACTORED CODE ***/
    558568
    559569   defineModelGroupUniform(modelGroups[TYPE_EXPLOSION], "cur_time", ATTRIB_UNIFORM,
     
    10601070}
    10611071
     1072/*** START OF REFACTORED CODE ***/
    10621073void window_size_callback(GLFWwindow* window, int width, int height) {
    10631074   cout << "Window resized to (" << width << ", " << height << ")" << endl;
     
    10731084   //glfwSetWindowAttrib(window, GLFW_DECORATED, GLFW_FALSE);
    10741085}
     1086/*** END OF REFACTORED CODE ***/
    10751087
    10761088void APIENTRY debugGlCallback(
     
    19451957
    19461958void initModelGroupAttribs(ShaderModelGroup& modelGroup) {
     1959/*** START OF REFACTORED CODE ***/
    19471960   glBindVertexArray(modelGroup.vao);
    19481961
    19491962   map<string, AttribInfo>::iterator it;
    19501963   for (it = modelGroup.attribs.begin(); it != modelGroup.attribs.end(); it++) {
     1964/*** END OF REFACTORED CODE ***/
    19511965      if (it->second.attribType == ATTRIB_UNIFORM) {
    19521966         it->second.buffer = glGetUniformLocation(modelGroup.shaderProgram, it->first.c_str());
     1967/*** START OF REFACTORED CODE ***/
    19531968      } else {
    19541969         glEnableVertexAttribArray(it->second.index);
     
    19691984      }
    19701985   }
     1986/*** START OF REFACTORED CODE ***/
    19711987}
    19721988
  • vulkan-ref.cpp

    ree75487 r5b02676  
    6161    vector<VkPresentModeKHR> presentModes;
    6262};
    63 /*** END OF REFACTORED CODE ***/
    6463
    6564struct Vertex {
     
    7372   glm::vec2 texCoord;
    7473};
     74/*** END OF REFACTORED CODE ***/
    7575
    7676struct UniformBufferObject {
     
    174174      vector<VkImage> swapChainImages;
    175175      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 ***/
    177179      vector<VkImageView> swapChainImageViews;
    178180/*** END OF REFACTORED CODE ***/
     
    369371            sceneIndices.data(), sizeof(uint16_t), sceneIndices.size());
    370372
     373/*** START OF REFACTORED CODE ***/
    371374         addAttributeDescription(scenePipeline, VK_FORMAT_R32G32B32_SFLOAT, offset_of(&Vertex::pos));
    372375         addAttributeDescription(scenePipeline, VK_FORMAT_R32G32B32_SFLOAT, offset_of(&Vertex::color));
    373376         addAttributeDescription(scenePipeline, VK_FORMAT_R32G32_SFLOAT, offset_of(&Vertex::texCoord));
     377/*** END OF REFACTORED CODE ***/
    374378
    375379         addDescriptorInfo(scenePipeline, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_SHADER_STAGE_VERTEX_BIT, &uniformBufferInfoList, nullptr);
     
    394398            overlayIndices.data(), sizeof(uint16_t), overlayIndices.size());
    395399
     400/*** START OF REFACTORED CODE ***/
    396401         addAttributeDescription(overlayPipeline, VK_FORMAT_R32G32B32_SFLOAT, offset_of(&OverlayVertex::pos));
    397402         addAttributeDescription(overlayPipeline, VK_FORMAT_R32G32_SFLOAT, offset_of(&OverlayVertex::texCoord));
     403/*** END OF REFACTORED CODE ***/
    398404
    399405         addDescriptorInfo(overlayPipeline, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr, &overlayImageInfo);
     
    809815            const void* vertexData, int vertexSize, size_t numVertices,
    810816            const void* indexData, int indexSize, size_t numIndices) {
     817/*** START OF REFACTORED CODE ***/
    811818         // Since there is only one array of vertex data, we use binding = 0
    812819         // I'll probably do that for the foreseeable future
     
    816823         info.bindingDescription.stride = vertexSize;
    817824         info.bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
     825/*** END OF REFACTORED CODE ***/
    818826
    819827         info.numVertices = numVertices;
     
    886894         VkPipelineVertexInputStateCreateInfo vertexInputInfo = {};
    887895         vertexInputInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
    888 /*** END OF REFACTORED CODE ***/
    889896
    890897         vertexInputInfo.vertexBindingDescriptionCount = 1;
     
    968975         pipelineLayoutInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
    969976         pipelineLayoutInfo.setLayoutCount = 1;
     977/*** END OF REFACTORED CODE ***/
    970978         pipelineLayoutInfo.pSetLayouts = &info.descriptorSetLayout;
    971979         pipelineLayoutInfo.pushConstantRangeCount = 0;
Note: See TracChangeset for help on using the changeset viewer.