Skip to content

Commit aa900bb

Browse files
clang-formatted Tutorials
1 parent 2146dde commit aa900bb

38 files changed

Lines changed: 1756 additions & 1491 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
python ../../../DiligentCore/BuildTools/FormatValidation/clang-format-validate.py --color never ^
22
--clang-format-executable ../../../DiligentCore/BuildTools/FormatValidation/clang-format_10.0.0.exe ^
3-
-r ../../SampleBase ^
3+
-r ../../SampleBase ../../Tutorials ^
44
--exclude ../../SampleBase/src/UWP ^
55
--exclude ../../SampleBase/src/Win32/resources

Tutorials/Common/src/TexturedCube.cpp

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,22 @@ RefCntAutoPtr<IBuffer> CreateVertexBuffer(IRenderDevice* pDevice)
4242

4343
// Cube vertices
4444

45-
// (-1,+1,+1)________________(+1,+1,+1)
45+
// (-1,+1,+1)________________(+1,+1,+1)
4646
// /| /|
4747
// / | / |
4848
// / | / |
4949
// / | / |
5050
//(-1,-1,+1) /____|__________/(+1,-1,+1)
51-
// | |__________|____|
51+
// | |__________|____|
5252
// | /(-1,+1,-1) | /(+1,+1,-1)
5353
// | / | /
5454
// | / | /
5555
// |/ | /
56-
// /_______________|/
56+
// /_______________|/
5757
// (-1,-1,-1) (+1,-1,-1)
58-
//
58+
//
5959

60+
// clang-format off
6061
Vertex CubeVerts[] =
6162
{
6263
{float3(-1,-1,-1), float2(0,1)},
@@ -89,6 +90,7 @@ RefCntAutoPtr<IBuffer> CreateVertexBuffer(IRenderDevice* pDevice)
8990
{float3(+1,+1,+1), float2(0,0)},
9091
{float3(-1,+1,+1), float2(1,0)}
9192
};
93+
// clang-format on
9294

9395
BufferDesc VertBuffDesc;
9496
VertBuffDesc.Name = "Cube vertex buffer";
@@ -107,6 +109,7 @@ RefCntAutoPtr<IBuffer> CreateVertexBuffer(IRenderDevice* pDevice)
107109

108110
RefCntAutoPtr<IBuffer> CreateIndexBuffer(IRenderDevice* pDevice)
109111
{
112+
// clang-format off
110113
Uint32 Indices[] =
111114
{
112115
2,0,1, 2,3,0,
@@ -116,6 +119,7 @@ RefCntAutoPtr<IBuffer> CreateIndexBuffer(IRenderDevice* pDevice)
116119
16,18,17, 16,19,18,
117120
20,21,22, 20,22,23
118121
};
122+
// clang-format on
119123

120124
BufferDesc IndBuffDesc;
121125
IndBuffDesc.Name = "Cube index buffer";
@@ -146,19 +150,20 @@ RefCntAutoPtr<IPipelineState> CreatePipelineState(IRenderDevice*
146150
IShaderSourceInputStreamFactory* pShaderSourceFactory,
147151
const char* VSFilePath,
148152
const char* PSFilePath,
149-
LayoutElement* LayoutElements /*= nullptr*/,
150-
Uint32 NumLayoutElements /*= 0*/,
151-
Uint8 SampleCount /*= 1*/)
153+
LayoutElement* LayoutElements /*= nullptr*/,
154+
Uint32 NumLayoutElements /*= 0*/,
155+
Uint8 SampleCount /*= 1*/)
152156
{
153157
PipelineStateDesc PSODesc;
154158

155159
// This is a graphics pipeline
156-
PSODesc.IsComputePipeline = false;
160+
PSODesc.IsComputePipeline = false;
157161

158162
// Pipeline state name is used by the engine to report issues.
159163
// It is always a good idea to give objects descriptive names.
160-
PSODesc.Name = "Cube PSO";
164+
PSODesc.Name = "Cube PSO";
161165

166+
// clang-format off
162167
// This tutorial will render to a single render target
163168
PSODesc.GraphicsPipeline.NumRenderTargets = 1;
164169
// Set render target format which is the format of the swap chain's color buffer
@@ -173,7 +178,7 @@ RefCntAutoPtr<IPipelineState> CreatePipelineState(IRenderDevice*
173178
PSODesc.GraphicsPipeline.RasterizerDesc.CullMode = CULL_MODE_BACK;
174179
// Enable depth testing
175180
PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = True;
176-
181+
// clang-format on
177182
ShaderCreateInfo ShaderCI;
178183
// Tell the system that the shader source code is in HLSL.
179184
// For OpenGL, the engine will convert this into GLSL under the hood.
@@ -205,6 +210,7 @@ RefCntAutoPtr<IPipelineState> CreatePipelineState(IRenderDevice*
205210

206211
// Define vertex shader input layout
207212
// This tutorial uses two types of input: per-vertex data and per-instance data.
213+
// clang-format off
208214
const LayoutElement DefaultLayoutElems[] =
209215
{
210216
// Per-vertex data - first buffer slot
@@ -213,25 +219,30 @@ RefCntAutoPtr<IPipelineState> CreatePipelineState(IRenderDevice*
213219
// Attribute 1 - texture coordinates
214220
LayoutElement{1, 0, 2, VT_FLOAT32, False}
215221
};
222+
// clang-format on
216223

217224
PSODesc.GraphicsPipeline.pVS = pVS;
218225
PSODesc.GraphicsPipeline.pPS = pPS;
219-
PSODesc.GraphicsPipeline.InputLayout.LayoutElements = LayoutElements != nullptr ? LayoutElements : DefaultLayoutElems;
226+
227+
PSODesc.GraphicsPipeline.InputLayout.LayoutElements = LayoutElements != nullptr ? LayoutElements : DefaultLayoutElems;
220228
PSODesc.GraphicsPipeline.InputLayout.NumElements = LayoutElements != nullptr ? NumLayoutElements : _countof(DefaultLayoutElems);
221229

222230
// Define variable type that will be used by default
223231
PSODesc.ResourceLayout.DefaultVariableType = SHADER_RESOURCE_VARIABLE_TYPE_STATIC;
224232

225233
// Shader variables should typically be mutable, which means they are expected
226234
// to change on a per-instance basis
235+
// clang-format off
227236
ShaderResourceVariableDesc Vars[] =
228237
{
229238
{SHADER_TYPE_PIXEL, "g_Texture", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}
230239
};
240+
// clang-format on
231241
PSODesc.ResourceLayout.Variables = Vars;
232242
PSODesc.ResourceLayout.NumVariables = _countof(Vars);
233243

234244
// Define static sampler for g_Texture. Static samplers should be used whenever possible
245+
// clang-format off
235246
SamplerDesc SamLinearClampDesc
236247
{
237248
FILTER_TYPE_LINEAR, FILTER_TYPE_LINEAR, FILTER_TYPE_LINEAR,
@@ -241,6 +252,7 @@ RefCntAutoPtr<IPipelineState> CreatePipelineState(IRenderDevice*
241252
{
242253
{SHADER_TYPE_PIXEL, "g_Texture", SamLinearClampDesc}
243254
};
255+
// clang-format on
244256
PSODesc.ResourceLayout.StaticSamplers = StaticSamplers;
245257
PSODesc.ResourceLayout.NumStaticSamplers = _countof(StaticSamplers);
246258

Tutorials/Common/src/TexturedCube.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* of the possibility of such damages.
2222
*/
2323

24-
#pragma once
24+
#pragma once
2525

2626
#include "RenderDevice.h"
2727
#include "Buffer.h"
@@ -43,10 +43,10 @@ RefCntAutoPtr<IPipelineState> CreatePipelineState(IRenderDevice*
4343
IShaderSourceInputStreamFactory* pShaderSourceFactory,
4444
const char* VSFilePath,
4545
const char* PSFilePath,
46-
LayoutElement* LayoutElements = nullptr,
47-
Uint32 NumLayoutElements = 0,
48-
Uint8 SampleCount = 1);
46+
LayoutElement* LayoutElements = nullptr,
47+
Uint32 NumLayoutElements = 0,
48+
Uint8 SampleCount = 1);
4949

50-
}
50+
} // namespace TexturedCube
5151

52-
}
52+
} // namespace Diligent

0 commit comments

Comments
 (0)