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"
|
2021-06-24 19:21:31 +00:00
|
|
|
#include "utils/ScopedAutoreleasePool.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
|
|
|
|
2018-08-13 06:23:27 +00:00
|
|
|
#include <glm/glm.hpp>
|
|
|
|
#include <glm/gtc/matrix_transform.hpp>
|
|
|
|
#include <glm/gtc/type_ptr.hpp>
|
2020-07-10 20:33:08 +00:00
|
|
|
#include <vector>
|
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() {
|
2020-07-10 20:33:08 +00:00
|
|
|
static const uint32_t indexData[6 * 6] = {0, 1, 2, 0, 2, 3,
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2020-07-10 20:33:08 +00:00
|
|
|
4, 5, 6, 4, 6, 7,
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2020-07-10 20:33:08 +00:00
|
|
|
8, 9, 10, 8, 10, 11,
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2020-07-10 20:33:08 +00:00
|
|
|
12, 13, 14, 12, 14, 15,
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2020-07-10 20:33:08 +00:00
|
|
|
16, 17, 18, 16, 18, 19,
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2020-07-10 20:33:08 +00:00
|
|
|
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] = {
|
2020-07-10 20:33:08 +00:00
|
|
|
-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] = {
|
2020-07-10 20:33:08 +00:00
|
|
|
-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,
|
2017-05-31 00:03:44 +00:00
|
|
|
};
|
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
|
|
|
|
2021-02-04 15:33:42 +00:00
|
|
|
queue = device.GetQueue();
|
2017-07-28 01:30:57 +00:00
|
|
|
swapchain = GetSwapChain(device);
|
2020-10-27 15:35:56 +00:00
|
|
|
swapchain.Configure(GetPreferredSwapChainTextureFormat(), wgpu::TextureUsage::RenderAttachment,
|
2019-08-27 08:21:39 +00:00
|
|
|
640, 480);
|
2017-05-31 00:03:44 +00:00
|
|
|
|
|
|
|
initBuffers();
|
|
|
|
|
2021-03-24 15:55:32 +00:00
|
|
|
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
2020-11-26 16:39:46 +00:00
|
|
|
[[block]] struct Camera {
|
2021-03-17 09:48:19 +00:00
|
|
|
view : mat4x4<f32>;
|
|
|
|
proj : mat4x4<f32>;
|
2017-05-31 00:03:44 +00:00
|
|
|
};
|
2021-01-19 14:18:51 +00:00
|
|
|
[[group(0), binding(0)]] var<uniform> camera : Camera;
|
2020-11-26 16:39:46 +00:00
|
|
|
|
|
|
|
[[block]] struct Model {
|
2021-03-17 09:48:19 +00:00
|
|
|
matrix : mat4x4<f32>;
|
2020-11-26 16:39:46 +00:00
|
|
|
};
|
2021-01-19 14:18:51 +00:00
|
|
|
[[group(0), binding(1)]] var<uniform> model : Model;
|
2020-11-26 16:39:46 +00:00
|
|
|
|
2021-04-13 14:52:44 +00:00
|
|
|
struct VertexOut {
|
|
|
|
[[location(2)]] f_col : vec3<f32>;
|
|
|
|
[[builtin(position)]] Position : vec4<f32>;
|
|
|
|
};
|
2020-11-26 16:39:46 +00:00
|
|
|
|
2021-04-13 14:52:44 +00:00
|
|
|
[[stage(vertex)]] fn main(
|
|
|
|
[[location(0)]] pos : vec3<f32>,
|
|
|
|
[[location(1)]] col : vec3<f32>) -> VertexOut {
|
|
|
|
var output : VertexOut;
|
|
|
|
output.f_col = col;
|
|
|
|
output.Position = camera.proj * camera.view * model.matrix * vec4<f32>(pos, 1.0);
|
|
|
|
return output;
|
2019-07-12 17:52:22 +00:00
|
|
|
})");
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2021-03-24 15:55:32 +00:00
|
|
|
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
2021-04-13 14:52:44 +00:00
|
|
|
[[stage(fragment)]] fn main(
|
|
|
|
[[location(2)]] f_col : vec3<f32>) -> [[location(0)]] vec4<f32> {
|
|
|
|
return vec4<f32>(f_col, 1.0);
|
2017-08-29 17:37:45 +00:00
|
|
|
})");
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2021-03-24 15:55:32 +00:00
|
|
|
wgpu::ShaderModule fsReflectionModule = utils::CreateShaderModule(device, R"(
|
2021-04-13 14:52:44 +00:00
|
|
|
[[stage(fragment)]] fn main(
|
|
|
|
[[location(2)]] f_col : vec3<f32>) -> [[location(0)]] vec4<f32> {
|
|
|
|
return vec4<f32>(mix(f_col, vec3<f32>(0.5, 0.5, 0.5), vec3<f32>(0.5, 0.5, 0.5)), 1.0);
|
2017-08-29 17:37:45 +00:00
|
|
|
})");
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2021-03-18 16:46:58 +00:00
|
|
|
wgpu::VertexAttribute attributes[2];
|
|
|
|
attributes[0].shaderLocation = 0;
|
|
|
|
attributes[0].offset = 0;
|
|
|
|
attributes[0].format = wgpu::VertexFormat::Float32x3;
|
|
|
|
attributes[1].shaderLocation = 1;
|
|
|
|
attributes[1].offset = 3 * sizeof(float);
|
|
|
|
attributes[1].format = wgpu::VertexFormat::Float32x3;
|
|
|
|
|
|
|
|
wgpu::VertexBufferLayout vertexBufferLayout;
|
|
|
|
vertexBufferLayout.attributeCount = 2;
|
|
|
|
vertexBufferLayout.attributes = attributes;
|
|
|
|
vertexBufferLayout.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, {
|
2021-03-18 16:46:58 +00:00
|
|
|
{0, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform},
|
|
|
|
{1, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform},
|
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
|
|
|
|
2020-07-10 20:33:08 +00:00
|
|
|
bindGroup[0] = utils::MakeBindGroup(
|
|
|
|
device, bgl,
|
|
|
|
{{0, cameraBuffer, 0, sizeof(CameraData)}, {1, transformBuffer[0], 0, sizeof(glm::mat4)}});
|
2018-12-05 07:18:30 +00:00
|
|
|
|
2020-07-10 20:33:08 +00:00
|
|
|
bindGroup[1] = utils::MakeBindGroup(
|
|
|
|
device, bgl,
|
|
|
|
{{0, cameraBuffer, 0, sizeof(CameraData)}, {1, transformBuffer[1], 0, sizeof(glm::mat4)}});
|
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
|
|
|
|
2021-03-18 16:46:58 +00:00
|
|
|
{
|
2021-05-21 05:01:38 +00:00
|
|
|
utils::ComboRenderPipelineDescriptor descriptor;
|
2021-03-18 16:46:58 +00:00
|
|
|
descriptor.vertex.module = vsModule;
|
|
|
|
descriptor.vertex.bufferCount = 1;
|
|
|
|
descriptor.vertex.buffers = &vertexBufferLayout;
|
|
|
|
|
|
|
|
descriptor.layout = pl;
|
|
|
|
descriptor.cFragment.module = fsModule;
|
|
|
|
descriptor.cTargets[0].format = GetPreferredSwapChainTextureFormat();
|
|
|
|
|
|
|
|
wgpu::DepthStencilState* depthStencil =
|
|
|
|
descriptor.EnableDepthStencil(wgpu::TextureFormat::Depth24PlusStencil8);
|
|
|
|
depthStencil->depthWriteEnabled = true;
|
|
|
|
depthStencil->depthCompare = wgpu::CompareFunction::Less;
|
|
|
|
|
2021-05-21 05:01:38 +00:00
|
|
|
pipeline = device.CreateRenderPipeline(&descriptor);
|
2021-03-18 16:46:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2021-05-21 05:01:38 +00:00
|
|
|
utils::ComboRenderPipelineDescriptor descriptor;
|
2021-03-18 16:46:58 +00:00
|
|
|
descriptor.vertex.module = vsModule;
|
|
|
|
descriptor.vertex.bufferCount = 1;
|
|
|
|
descriptor.vertex.buffers = &vertexBufferLayout;
|
|
|
|
|
|
|
|
descriptor.layout = pl;
|
|
|
|
descriptor.cFragment.module = fsModule;
|
|
|
|
descriptor.cTargets[0].format = GetPreferredSwapChainTextureFormat();
|
|
|
|
|
|
|
|
wgpu::DepthStencilState* depthStencil =
|
|
|
|
descriptor.EnableDepthStencil(wgpu::TextureFormat::Depth24PlusStencil8);
|
|
|
|
depthStencil->stencilFront.passOp = wgpu::StencilOperation::Replace;
|
|
|
|
depthStencil->stencilBack.passOp = wgpu::StencilOperation::Replace;
|
|
|
|
depthStencil->depthCompare = wgpu::CompareFunction::Less;
|
|
|
|
|
2021-05-21 05:01:38 +00:00
|
|
|
planePipeline = device.CreateRenderPipeline(&descriptor);
|
2021-03-18 16:46:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2021-05-21 05:01:38 +00:00
|
|
|
utils::ComboRenderPipelineDescriptor descriptor;
|
2021-03-18 16:46:58 +00:00
|
|
|
descriptor.vertex.module = vsModule;
|
|
|
|
descriptor.vertex.bufferCount = 1;
|
|
|
|
descriptor.vertex.buffers = &vertexBufferLayout;
|
|
|
|
|
|
|
|
descriptor.layout = pl;
|
|
|
|
descriptor.cFragment.module = fsReflectionModule;
|
|
|
|
descriptor.cTargets[0].format = GetPreferredSwapChainTextureFormat();
|
|
|
|
|
|
|
|
wgpu::DepthStencilState* depthStencil =
|
|
|
|
descriptor.EnableDepthStencil(wgpu::TextureFormat::Depth24PlusStencil8);
|
|
|
|
depthStencil->stencilFront.compare = wgpu::CompareFunction::Equal;
|
|
|
|
depthStencil->stencilBack.compare = wgpu::CompareFunction::Equal;
|
|
|
|
depthStencil->stencilFront.passOp = wgpu::StencilOperation::Replace;
|
|
|
|
depthStencil->stencilBack.passOp = wgpu::StencilOperation::Replace;
|
|
|
|
depthStencil->depthWriteEnabled = true;
|
|
|
|
depthStencil->depthCompare = wgpu::CompareFunction::Less;
|
|
|
|
|
2021-05-21 05:01:38 +00:00
|
|
|
reflectionPipeline = device.CreateRenderPipeline(&descriptor);
|
2021-03-18 16:46:58 +00:00
|
|
|
}
|
2017-05-31 00:03:44 +00:00
|
|
|
|
|
|
|
cameraData.proj = glm::perspective(glm::radians(45.0f), 1.f, 1.0f, 100.0f);
|
|
|
|
}
|
|
|
|
|
2020-07-10 20:33:08 +00:00
|
|
|
struct {
|
|
|
|
uint32_t a;
|
|
|
|
float b;
|
|
|
|
} s;
|
2017-05-31 00:03:44 +00:00
|
|
|
void frame() {
|
|
|
|
s.a = (s.a + 1) % 256;
|
2017-07-11 01:44:06 +00:00
|
|
|
s.b += 0.01f;
|
2020-07-10 20:33:08 +00:00
|
|
|
if (s.b >= 1.0f) {
|
|
|
|
s.b = 0.0f;
|
|
|
|
}
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2020-07-10 20:33:08 +00:00
|
|
|
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), 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);
|
2020-11-25 08:54:14 +00:00
|
|
|
pass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32);
|
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()) {
|
2021-06-24 19:21:31 +00:00
|
|
|
utils::ScopedAutoreleasePool pool;
|
2017-05-31 00:03:44 +00:00
|
|
|
frame();
|
2017-07-17 21:13:57 +00:00
|
|
|
utils::USleep(16000);
|
2017-05-31 00:03:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO release stuff
|
|
|
|
}
|