2018-07-18 09:40:26 +00:00
|
|
|
// Copyright 2017 The Dawn Authors
|
2017-05-31 00:03:44 +00:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2017-06-19 17:15:13 +00:00
|
|
|
#include "SampleUtils.h"
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2018-12-10 19:47:22 +00:00
|
|
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
2017-07-17 21:13:57 +00:00
|
|
|
#include "utils/SystemUtils.h"
|
2019-10-25 11:36:47 +00:00
|
|
|
#include "utils/WGPUHelpers.h"
|
2017-06-19 17:09:41 +00:00
|
|
|
|
2017-05-31 00:03:44 +00:00
|
|
|
#include <vector>
|
2018-08-13 06:23:27 +00:00
|
|
|
#include <glm/glm.hpp>
|
|
|
|
#include <glm/gtc/matrix_transform.hpp>
|
|
|
|
#include <glm/gtc/type_ptr.hpp>
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2019-10-25 11:36:47 +00:00
|
|
|
wgpu::Device device;
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2019-10-25 11:36:47 +00:00
|
|
|
wgpu::Buffer indexBuffer;
|
|
|
|
wgpu::Buffer vertexBuffer;
|
|
|
|
wgpu::Buffer planeBuffer;
|
|
|
|
wgpu::Buffer cameraBuffer;
|
|
|
|
wgpu::Buffer transformBuffer[2];
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2019-10-25 11:36:47 +00:00
|
|
|
wgpu::BindGroup cameraBindGroup;
|
|
|
|
wgpu::BindGroup bindGroup[2];
|
|
|
|
wgpu::BindGroup cubeTransformBindGroup[2];
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2019-10-25 11:36:47 +00:00
|
|
|
wgpu::Queue queue;
|
|
|
|
wgpu::SwapChain swapchain;
|
|
|
|
wgpu::TextureView depthStencilView;
|
|
|
|
wgpu::RenderPipeline pipeline;
|
|
|
|
wgpu::RenderPipeline planePipeline;
|
|
|
|
wgpu::RenderPipeline reflectionPipeline;
|
2017-05-31 00:03:44 +00:00
|
|
|
|
|
|
|
void initBuffers() {
|
|
|
|
static const uint32_t indexData[6*6] = {
|
|
|
|
0, 1, 2,
|
|
|
|
0, 2, 3,
|
|
|
|
|
|
|
|
4, 5, 6,
|
|
|
|
4, 6, 7,
|
|
|
|
|
|
|
|
8, 9, 10,
|
|
|
|
8, 10, 11,
|
|
|
|
|
|
|
|
12, 13, 14,
|
|
|
|
12, 14, 15,
|
|
|
|
|
|
|
|
16, 17, 18,
|
|
|
|
16, 18, 19,
|
|
|
|
|
|
|
|
20, 21, 22,
|
|
|
|
20, 22, 23
|
|
|
|
};
|
2019-08-27 08:21:39 +00:00
|
|
|
indexBuffer =
|
2019-10-25 11:36:47 +00:00
|
|
|
utils::CreateBufferFromData(device, indexData, sizeof(indexData), wgpu::BufferUsage::Index);
|
2017-05-31 00:03:44 +00:00
|
|
|
|
|
|
|
static const float vertexData[6 * 4 * 6] = {
|
|
|
|
-1.0, -1.0, 1.0, 1.0, 0.0, 0.0,
|
|
|
|
1.0, -1.0, 1.0, 1.0, 0.0, 0.0,
|
|
|
|
1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
|
|
|
|
-1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
|
|
|
|
|
|
|
|
-1.0, -1.0, -1.0, 1.0, 1.0, 0.0,
|
|
|
|
-1.0, 1.0, -1.0, 1.0, 1.0, 0.0,
|
|
|
|
1.0, 1.0, -1.0, 1.0, 1.0, 0.0,
|
|
|
|
1.0, -1.0, -1.0, 1.0, 1.0, 0.0,
|
|
|
|
|
|
|
|
-1.0, 1.0, -1.0, 1.0, 0.0, 1.0,
|
|
|
|
-1.0, 1.0, 1.0, 1.0, 0.0, 1.0,
|
|
|
|
1.0, 1.0, 1.0, 1.0, 0.0, 1.0,
|
|
|
|
1.0, 1.0, -1.0, 1.0, 0.0, 1.0,
|
|
|
|
|
|
|
|
-1.0, -1.0, -1.0, 0.0, 1.0, 0.0,
|
|
|
|
1.0, -1.0, -1.0, 0.0, 1.0, 0.0,
|
|
|
|
1.0, -1.0, 1.0, 0.0, 1.0, 0.0,
|
|
|
|
-1.0, -1.0, 1.0, 0.0, 1.0, 0.0,
|
|
|
|
|
|
|
|
1.0, -1.0, -1.0, 0.0, 1.0, 1.0,
|
|
|
|
1.0, 1.0, -1.0, 0.0, 1.0, 1.0,
|
|
|
|
1.0, 1.0, 1.0, 0.0, 1.0, 1.0,
|
|
|
|
1.0, -1.0, 1.0, 0.0, 1.0, 1.0,
|
|
|
|
|
|
|
|
-1.0, -1.0, -1.0, 1.0, 1.0, 1.0,
|
|
|
|
-1.0, -1.0, 1.0, 1.0, 1.0, 1.0,
|
|
|
|
-1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
|
|
|
|
-1.0, 1.0, -1.0, 1.0, 1.0, 1.0
|
|
|
|
};
|
2019-08-27 08:21:39 +00:00
|
|
|
vertexBuffer = utils::CreateBufferFromData(device, vertexData, sizeof(vertexData),
|
2019-10-25 11:36:47 +00:00
|
|
|
wgpu::BufferUsage::Vertex);
|
2017-05-31 00:03:44 +00:00
|
|
|
|
|
|
|
static const float planeData[6 * 4] = {
|
|
|
|
-2.0, -1.0, -2.0, 0.5, 0.5, 0.5,
|
|
|
|
2.0, -1.0, -2.0, 0.5, 0.5, 0.5,
|
|
|
|
2.0, -1.0, 2.0, 0.5, 0.5, 0.5,
|
|
|
|
-2.0, -1.0, 2.0, 0.5, 0.5, 0.5,
|
|
|
|
};
|
2019-08-27 08:21:39 +00:00
|
|
|
planeBuffer = utils::CreateBufferFromData(device, planeData, sizeof(planeData),
|
2019-10-25 11:36:47 +00:00
|
|
|
wgpu::BufferUsage::Vertex);
|
2017-05-31 00:03:44 +00:00
|
|
|
}
|
|
|
|
|
2017-06-02 18:31:53 +00:00
|
|
|
struct CameraData {
|
2017-05-31 00:03:44 +00:00
|
|
|
glm::mat4 view;
|
|
|
|
glm::mat4 proj;
|
|
|
|
} cameraData;
|
|
|
|
|
|
|
|
void init() {
|
2018-07-18 12:06:10 +00:00
|
|
|
device = CreateCppDawnDevice();
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2020-04-17 16:45:17 +00:00
|
|
|
queue = device.GetDefaultQueue();
|
2017-07-28 01:30:57 +00:00
|
|
|
swapchain = GetSwapChain(device);
|
2019-10-25 11:36:47 +00:00
|
|
|
swapchain.Configure(GetPreferredSwapChainTextureFormat(), wgpu::TextureUsage::OutputAttachment,
|
2019-08-27 08:21:39 +00:00
|
|
|
640, 480);
|
2017-05-31 00:03:44 +00:00
|
|
|
|
|
|
|
initBuffers();
|
|
|
|
|
2019-10-25 11:36:47 +00:00
|
|
|
wgpu::ShaderModule vsModule =
|
2019-08-27 08:42:29 +00:00
|
|
|
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
2017-05-31 00:03:44 +00:00
|
|
|
#version 450
|
|
|
|
layout(set = 0, binding = 0) uniform cameraData {
|
|
|
|
mat4 view;
|
|
|
|
mat4 proj;
|
|
|
|
} camera;
|
|
|
|
layout(set = 0, binding = 1) uniform modelData {
|
|
|
|
mat4 modelMatrix;
|
|
|
|
};
|
|
|
|
layout(location = 0) in vec3 pos;
|
|
|
|
layout(location = 1) in vec3 col;
|
|
|
|
layout(location = 2) out vec3 f_col;
|
|
|
|
void main() {
|
|
|
|
f_col = col;
|
|
|
|
gl_Position = camera.proj * camera.view * modelMatrix * vec4(pos, 1.0);
|
2019-07-12 17:52:22 +00:00
|
|
|
})");
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2019-10-25 11:36:47 +00:00
|
|
|
wgpu::ShaderModule fsModule =
|
2019-08-27 08:42:29 +00:00
|
|
|
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
2017-05-31 00:03:44 +00:00
|
|
|
#version 450
|
|
|
|
layout(location = 2) in vec3 f_col;
|
2017-08-29 17:37:45 +00:00
|
|
|
layout(location = 0) out vec4 fragColor;
|
2017-05-31 00:03:44 +00:00
|
|
|
void main() {
|
|
|
|
fragColor = vec4(f_col, 1.0);
|
2017-08-29 17:37:45 +00:00
|
|
|
})");
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2019-10-25 11:36:47 +00:00
|
|
|
wgpu::ShaderModule fsReflectionModule =
|
2019-08-27 08:42:29 +00:00
|
|
|
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
2017-05-31 00:03:44 +00:00
|
|
|
#version 450
|
|
|
|
layout(location = 2) in vec3 f_col;
|
2017-08-29 17:37:45 +00:00
|
|
|
layout(location = 0) out vec4 fragColor;
|
2017-05-31 00:03:44 +00:00
|
|
|
void main() {
|
|
|
|
fragColor = vec4(mix(f_col, vec3(0.5, 0.5, 0.5), 0.5), 1.0);
|
2017-08-29 17:37:45 +00:00
|
|
|
})");
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2019-11-07 22:23:29 +00:00
|
|
|
utils::ComboVertexStateDescriptor vertexState;
|
|
|
|
vertexState.cVertexBuffers[0].attributeCount = 2;
|
|
|
|
vertexState.cAttributes[0].format = wgpu::VertexFormat::Float3;
|
|
|
|
vertexState.cAttributes[1].shaderLocation = 1;
|
|
|
|
vertexState.cAttributes[1].offset = 3 * sizeof(float);
|
|
|
|
vertexState.cAttributes[1].format = wgpu::VertexFormat::Float3;
|
2019-03-28 05:09:01 +00:00
|
|
|
|
2019-11-07 22:23:29 +00:00
|
|
|
vertexState.vertexBufferCount = 1;
|
|
|
|
vertexState.cVertexBuffers[0].arrayStride = 6 * sizeof(float);
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2018-07-10 19:23:50 +00:00
|
|
|
auto bgl = utils::MakeBindGroupLayout(
|
|
|
|
device, {
|
2019-10-25 11:36:47 +00:00
|
|
|
{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer},
|
|
|
|
{1, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer},
|
2018-07-10 19:23:50 +00:00
|
|
|
});
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2019-10-25 11:36:47 +00:00
|
|
|
wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2019-10-25 11:36:47 +00:00
|
|
|
wgpu::BufferDescriptor cameraBufDesc;
|
2018-08-22 13:37:29 +00:00
|
|
|
cameraBufDesc.size = sizeof(CameraData);
|
2019-10-25 11:36:47 +00:00
|
|
|
cameraBufDesc.usage = wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::Uniform;
|
2018-08-22 13:37:29 +00:00
|
|
|
cameraBuffer = device.CreateBuffer(&cameraBufDesc);
|
2017-05-31 00:03:44 +00:00
|
|
|
|
|
|
|
glm::mat4 transform(1.0);
|
2019-08-27 08:21:39 +00:00
|
|
|
transformBuffer[0] = utils::CreateBufferFromData(device, &transform, sizeof(glm::mat4),
|
2019-10-25 11:36:47 +00:00
|
|
|
wgpu::BufferUsage::Uniform);
|
2017-05-31 00:03:44 +00:00
|
|
|
|
|
|
|
transform = glm::translate(transform, glm::vec3(0.f, -2.f, 0.f));
|
2019-08-27 08:21:39 +00:00
|
|
|
transformBuffer[1] = utils::CreateBufferFromData(device, &transform, sizeof(glm::mat4),
|
2019-10-25 11:36:47 +00:00
|
|
|
wgpu::BufferUsage::Uniform);
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2018-12-05 07:18:30 +00:00
|
|
|
bindGroup[0] = utils::MakeBindGroup(device, bgl, {
|
2018-12-07 12:31:53 +00:00
|
|
|
{0, cameraBuffer, 0, sizeof(CameraData)},
|
|
|
|
{1, transformBuffer[0], 0, sizeof(glm::mat4)}
|
2018-12-05 07:18:30 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
bindGroup[1] = utils::MakeBindGroup(device, bgl, {
|
2018-12-07 12:31:53 +00:00
|
|
|
{0, cameraBuffer, 0, sizeof(CameraData)},
|
|
|
|
{1, transformBuffer[1], 0, sizeof(glm::mat4)}
|
2018-12-05 07:18:30 +00:00
|
|
|
});
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2017-07-28 01:30:57 +00:00
|
|
|
depthStencilView = CreateDefaultDepthStencilView(device);
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2018-12-10 19:47:22 +00:00
|
|
|
utils::ComboRenderPipelineDescriptor descriptor(device);
|
|
|
|
descriptor.layout = pl;
|
2019-09-05 09:35:07 +00:00
|
|
|
descriptor.vertexStage.module = vsModule;
|
2018-12-10 19:47:22 +00:00
|
|
|
descriptor.cFragmentStage.module = fsModule;
|
2019-11-07 22:23:29 +00:00
|
|
|
descriptor.vertexState = &vertexState;
|
2019-02-15 02:20:57 +00:00
|
|
|
descriptor.depthStencilState = &descriptor.cDepthStencilState;
|
2019-10-25 11:36:47 +00:00
|
|
|
descriptor.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
|
2019-09-20 23:22:27 +00:00
|
|
|
descriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat();
|
2019-01-04 04:28:37 +00:00
|
|
|
descriptor.cDepthStencilState.depthWriteEnabled = true;
|
2019-10-25 11:36:47 +00:00
|
|
|
descriptor.cDepthStencilState.depthCompare = wgpu::CompareFunction::Less;
|
2018-12-10 19:47:22 +00:00
|
|
|
|
|
|
|
pipeline = device.CreateRenderPipeline(&descriptor);
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2018-12-10 19:47:22 +00:00
|
|
|
utils::ComboRenderPipelineDescriptor pDescriptor(device);
|
|
|
|
pDescriptor.layout = pl;
|
2019-09-05 09:35:07 +00:00
|
|
|
pDescriptor.vertexStage.module = vsModule;
|
2018-12-10 19:47:22 +00:00
|
|
|
pDescriptor.cFragmentStage.module = fsModule;
|
2019-11-07 22:23:29 +00:00
|
|
|
pDescriptor.vertexState = &vertexState;
|
2019-02-15 02:20:57 +00:00
|
|
|
pDescriptor.depthStencilState = &pDescriptor.cDepthStencilState;
|
2019-10-25 11:36:47 +00:00
|
|
|
pDescriptor.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
|
2019-09-20 23:22:27 +00:00
|
|
|
pDescriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat();
|
2019-10-25 11:36:47 +00:00
|
|
|
pDescriptor.cDepthStencilState.stencilFront.passOp = wgpu::StencilOperation::Replace;
|
|
|
|
pDescriptor.cDepthStencilState.stencilBack.passOp = wgpu::StencilOperation::Replace;
|
|
|
|
pDescriptor.cDepthStencilState.depthCompare = wgpu::CompareFunction::Less;
|
2018-12-10 19:47:22 +00:00
|
|
|
|
|
|
|
planePipeline = device.CreateRenderPipeline(&pDescriptor);
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2018-12-10 19:47:22 +00:00
|
|
|
utils::ComboRenderPipelineDescriptor rfDescriptor(device);
|
|
|
|
rfDescriptor.layout = pl;
|
2019-09-05 09:35:07 +00:00
|
|
|
rfDescriptor.vertexStage.module = vsModule;
|
2018-12-10 19:47:22 +00:00
|
|
|
rfDescriptor.cFragmentStage.module = fsReflectionModule;
|
2019-11-07 22:23:29 +00:00
|
|
|
rfDescriptor.vertexState = &vertexState;
|
2019-02-15 02:20:57 +00:00
|
|
|
rfDescriptor.depthStencilState = &rfDescriptor.cDepthStencilState;
|
2019-10-25 11:36:47 +00:00
|
|
|
rfDescriptor.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
|
2019-09-20 23:22:27 +00:00
|
|
|
rfDescriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat();
|
2019-10-25 11:36:47 +00:00
|
|
|
rfDescriptor.cDepthStencilState.stencilFront.compare = wgpu::CompareFunction::Equal;
|
|
|
|
rfDescriptor.cDepthStencilState.stencilBack.compare = wgpu::CompareFunction::Equal;
|
|
|
|
rfDescriptor.cDepthStencilState.stencilFront.passOp = wgpu::StencilOperation::Replace;
|
|
|
|
rfDescriptor.cDepthStencilState.stencilBack.passOp = wgpu::StencilOperation::Replace;
|
2019-01-04 04:28:37 +00:00
|
|
|
rfDescriptor.cDepthStencilState.depthWriteEnabled = true;
|
2019-10-25 11:36:47 +00:00
|
|
|
rfDescriptor.cDepthStencilState.depthCompare = wgpu::CompareFunction::Less;
|
2018-12-10 19:47:22 +00:00
|
|
|
|
|
|
|
reflectionPipeline = device.CreateRenderPipeline(&rfDescriptor);
|
2017-05-31 00:03:44 +00:00
|
|
|
|
|
|
|
cameraData.proj = glm::perspective(glm::radians(45.0f), 1.f, 1.0f, 100.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct {uint32_t a; float b;} s;
|
|
|
|
void frame() {
|
|
|
|
s.a = (s.a + 1) % 256;
|
2017-07-11 01:44:06 +00:00
|
|
|
s.b += 0.01f;
|
2017-05-31 00:03:44 +00:00
|
|
|
if (s.b >= 1.0f) {s.b = 0.0f;}
|
|
|
|
|
|
|
|
cameraData.view = glm::lookAt(
|
|
|
|
glm::vec3(8.f * std::sin(glm::radians(s.b * 360.f)), 2.f, 8.f * std::cos(glm::radians(s.b * 360.f))),
|
|
|
|
glm::vec3(0.0f, 0.0f, 0.0f),
|
2019-09-20 23:53:27 +00:00
|
|
|
glm::vec3(0.0f, 1.0f, 0.0f)
|
2017-05-31 00:03:44 +00:00
|
|
|
);
|
|
|
|
|
2020-06-02 09:24:39 +00:00
|
|
|
queue.WriteBuffer(cameraBuffer, 0, &cameraData, sizeof(CameraData));
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2019-11-12 18:30:11 +00:00
|
|
|
wgpu::TextureView backbufferView = swapchain.GetCurrentTextureView();
|
|
|
|
utils::ComboRenderPassDescriptor renderPass({backbufferView}, depthStencilView);
|
2017-07-28 01:30:57 +00:00
|
|
|
|
2019-10-25 11:36:47 +00:00
|
|
|
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
2018-09-21 00:24:37 +00:00
|
|
|
{
|
2019-10-25 11:36:47 +00:00
|
|
|
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
2018-12-21 10:40:26 +00:00
|
|
|
pass.SetPipeline(pipeline);
|
2019-10-09 16:08:42 +00:00
|
|
|
pass.SetBindGroup(0, bindGroup[0]);
|
2019-10-10 07:29:58 +00:00
|
|
|
pass.SetVertexBuffer(0, vertexBuffer);
|
2019-10-10 17:21:48 +00:00
|
|
|
pass.SetIndexBuffer(indexBuffer);
|
2020-03-31 16:21:35 +00:00
|
|
|
pass.DrawIndexed(36);
|
2018-09-21 00:24:37 +00:00
|
|
|
|
|
|
|
pass.SetStencilReference(0x1);
|
2018-12-21 10:40:26 +00:00
|
|
|
pass.SetPipeline(planePipeline);
|
2019-10-09 16:08:42 +00:00
|
|
|
pass.SetBindGroup(0, bindGroup[0]);
|
2019-10-10 07:29:58 +00:00
|
|
|
pass.SetVertexBuffer(0, planeBuffer);
|
2020-03-31 16:21:35 +00:00
|
|
|
pass.DrawIndexed(6);
|
2018-09-21 00:24:37 +00:00
|
|
|
|
2018-12-21 10:40:26 +00:00
|
|
|
pass.SetPipeline(reflectionPipeline);
|
2019-10-10 07:29:58 +00:00
|
|
|
pass.SetVertexBuffer(0, vertexBuffer);
|
2019-10-09 16:08:42 +00:00
|
|
|
pass.SetBindGroup(0, bindGroup[1]);
|
2020-03-31 16:21:35 +00:00
|
|
|
pass.DrawIndexed(36);
|
2018-09-21 00:24:37 +00:00
|
|
|
|
|
|
|
pass.EndPass();
|
|
|
|
}
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2019-10-25 11:36:47 +00:00
|
|
|
wgpu::CommandBuffer commands = encoder.Finish();
|
2017-05-31 00:03:44 +00:00
|
|
|
queue.Submit(1, &commands);
|
2019-11-12 18:30:11 +00:00
|
|
|
swapchain.Present();
|
2017-07-28 01:30:57 +00:00
|
|
|
DoFlush();
|
2017-05-31 00:03:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, const char* argv[]) {
|
2017-06-19 17:15:13 +00:00
|
|
|
if (!InitSample(argc, argv)) {
|
2017-05-31 00:03:44 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
init();
|
|
|
|
|
|
|
|
while (!ShouldQuit()) {
|
|
|
|
frame();
|
2017-07-17 21:13:57 +00:00
|
|
|
utils::USleep(16000);
|
2017-05-31 00:03:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO release stuff
|
|
|
|
}
|