-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreference-grid.cc
59 lines (50 loc) · 2.1 KB
/
reference-grid.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
// Copyright(c) Leonardo Romor <[email protected]>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://gnu.org/licenses/gpl-2.0.txt>
#include "reference-grid.h"
#include "vulkan-core.h"
#include "shaders/grid.vert.h"
#include "shaders/grid.frag.h"
#include <iostream>
void ReferenceGrid::Register(
space::core::VkAppContext *context,
vk::UniquePipelineLayout *pipeline_layout,
vk::UniqueRenderPass *render_pass,
vk::SampleCountFlagBits nsamples,
vk::UniquePipelineCache *pipeline_cache) {
// Instantiate the shaders
vk::UniqueShaderModule vertex =
context->device->createShaderModuleUnique(
vk::ShaderModuleCreateInfo(
vk::ShaderModuleCreateFlags(), sizeof(grid_vert), grid_vert));
vk::UniqueShaderModule frag =
context->device->createShaderModuleUnique(
vk::ShaderModuleCreateInfo(
vk::ShaderModuleCreateFlags(), sizeof(grid_frag), grid_frag));
pipeline_ = space::core::GraphicsPipelineBuilder(
&context->device, pipeline_layout, render_pass, nsamples)
.DepthBuffered(true)
.SetPrimitiveTopology(vk::PrimitiveTopology::eTriangleList)
.SetPolygoneMode(vk::PolygonMode::eFill)
.AddVertexShader(*vertex)
.AddFragmentShader(*frag)
.EnableDynamicState(vk::DynamicState::eScissor)
.EnableDynamicState(vk::DynamicState::eViewport)
.Create(pipeline_cache);
}
void ReferenceGrid::Draw(const vk::UniqueCommandBuffer *command_buffer) {
(*command_buffer)->bindPipeline(
vk::PipelineBindPoint::eGraphics, pipeline_.get());
(*command_buffer)->draw(6, 1, 0, 0);
}