~untaugh/meteormaker

74c3c21b6f57ad429b6648966218b6787e124095 — Oskar Rundgren a month ago 3acb793
Clean cmake file. Rename shape shader.
7 files changed, 30 insertions(+), 33 deletions(-)

M CMakeLists.txt
M render_vulkan.cc
M shader.h
R shader.frag => shape.frag
R shader.vert => shape.vert
M sprite_pipeline.cc
M text_pipeline.cc
M CMakeLists.txt => CMakeLists.txt +21 -24
@@ 1,10 1,14 @@
cmake_minimum_required (VERSION 3.0)
cmake_minimum_required (VERSION 3.12)

project(MeteorMaker)
project(MeteorMaker VERSION 0.1)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Werror -Wpedantic -std=c++17")

add_executable(metmak meteormaker.cc render_vulkan.cc shape.cc meteor.cc star.cc sprite.cc mouse.cc vertex.cc time.cc text_pipeline.cc text_render.cc sprite_pipeline.cc)
set(sources meteormaker.cc render_vulkan.cc shape.cc meteor.cc
  star.cc sprite.cc mouse.cc vertex.cc time.cc text_pipeline.cc
  text_render.cc sprite_pipeline.cc)

add_executable(metmak ${sources})

find_package(glfw3 REQUIRED)
find_package(Vulkan REQUIRED)


@@ 18,27 22,20 @@ target_link_libraries(metmak Freetype::Freetype)
target_include_directories(metmak PRIVATE Vulkan::Vulkan)
target_include_directories(metmak PRIVATE Freetype)

add_custom_command(OUTPUT vert.spv COMMAND glslangValidator -V ${CMAKE_CURRENT_SOURCE_DIR}/shader.vert MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/shader.vert)
add_custom_command(OUTPUT frag.spv COMMAND glslangValidator -V ${CMAKE_CURRENT_SOURCE_DIR}/shader.frag MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/shader.frag)
add_custom_command(OUTPUT vert_sprite.spv
  COMMAND glslangValidator -V ${CMAKE_CURRENT_SOURCE_DIR}/sprite.vert -o vert_sprite.spv
  MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/sprite.vert)
add_custom_command(OUTPUT frag_sprite.spv
  COMMAND glslangValidator -V ${CMAKE_CURRENT_SOURCE_DIR}/sprite.frag -o frag_sprite.spv
  MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/sprite.frag)
add_custom_command(OUTPUT vert_text.spv
  COMMAND glslangValidator -V ${CMAKE_CURRENT_SOURCE_DIR}/text.vert -o vert_text.spv
  MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/text.vert)
add_custom_command(OUTPUT frag_text.spv
  COMMAND glslangValidator -V ${CMAKE_CURRENT_SOURCE_DIR}/text.frag -o frag_text.spv
  MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/text.frag)
add_custom_command(OUTPUT vert_text_correct.spv
  COMMAND glslangValidator -V ${CMAKE_CURRENT_SOURCE_DIR}/text_correct.vert -o vert_text_correct.spv
  MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/text_correct.vert)
add_custom_command(OUTPUT frag_text_correct.spv
  COMMAND glslangValidator -V ${CMAKE_CURRENT_SOURCE_DIR}/text_correct.frag -o frag_text_correct.spv
  MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/text_correct.frag)
add_custom_target(shaders DEPENDS vert.spv frag.spv vert_sprite.spv frag_sprite.spv vert_text.spv frag_text.spv vert_text_correct.spv frag_text_correct.spv)
# Shaders
set(shaders sprite.vert sprite.frag shape.vert shape.frag
  text.vert text.frag text_correct.vert text_correct.frag)

foreach(shader ${shaders})
  add_custom_command(
    OUTPUT ${shader}.spv
    COMMAND glslangValidator -V ${CMAKE_CURRENT_SOURCE_DIR}/${shader} -o ${shader}.spv
    MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${shader})
endforeach(shader)

list(TRANSFORM shaders APPEND ".spv")
add_custom_target(shaders DEPENDS ${shaders})
add_dependencies(metmak shaders)

# Textures
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/textures DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

M render_vulkan.cc => render_vulkan.cc +2 -2
@@ 826,8 826,8 @@ RenderVulkan::createPipelineLayout(VkDescriptorSetLayout &layout,

VkPipeline RenderVulkan::createPipeline() const
{
  Shader vertShader(engine.device, "vert.spv");
  Shader fragShader(engine.device, "frag.spv");
  Shader vertShader(engine.device, "shape.vert.spv");
  Shader fragShader(engine.device, "shape.frag.spv");

  VkPipelineShaderStageCreateInfo vertShaderStageInfo = {};
  vertShaderStageInfo.sType =

M shader.h => shader.h +1 -1
@@ 21,7 21,7 @@ public:

    if (!file.is_open())
    {
      throw std::runtime_error("Failed to open file!");
      throw std::runtime_error("Failed to open shader file!");
    }

    size_t fileSize = (size_t)file.tellg();

R shader.frag => shape.frag +0 -0

R shader.vert => shape.vert +0 -0

M sprite_pipeline.cc => sprite_pipeline.cc +2 -2
@@ 88,8 88,8 @@ VkPipeline SpritePipeline::createPipeline
 VkPipelineLayout pipelineLayout,
 VkRenderPass renderPass) const
{
  Shader vertShader(device, "vert_sprite.spv");
  Shader fragShader(device, "frag_sprite.spv");
  Shader vertShader(device, "sprite.vert.spv");
  Shader fragShader(device, "sprite.frag.spv");

  VkPipelineShaderStageCreateInfo vertShaderStageInfo = {};
  vertShaderStageInfo.sType =

M text_pipeline.cc => text_pipeline.cc +4 -4
@@ 151,11 151,11 @@ VkPipeline TextPipeline::createPipeline
 TextPipelineType type) const
{
  Shader vertShader(device, type == FILL
                    ? "vert_text.spv"
                    : "vert_text_correct.spv");
                    ? "text.vert.spv"
                    : "text_correct.vert.spv");
  Shader fragShader(device, type == FILL
                    ? "frag_text.spv"
                    : "frag_text_correct.spv");
                    ? "text.frag.spv"
                    : "text_correct.frag.spv");

  VkPipelineShaderStageCreateInfo vertShaderStageInfo = {};
  vertShaderStageInfo.sType =