Browse Source

fix : mesh project update with recent api

Heedong Lee 3 years ago
parent
commit
d0b064da7f
1 changed files with 16 additions and 16 deletions
  1. 16
    16
      Samples/Mesh/Mesh.cpp

+ 16
- 16
Samples/Mesh/Mesh.cpp View File

@@ -49,7 +49,7 @@ public:
49 49
 		}
50 50
 	};
51 51
 
52
-	SampleObjMesh() 
52
+	SampleObjMesh()
53 53
 	{
54 54
 		vertices.Reserve(100);
55 55
 		indices.Reserve(100);
@@ -64,7 +64,7 @@ public:
64 64
 		if (!tinyobj::LoadObj(&attrib, &shapes, &materials, &err, InPath)) {
65 65
 			throw std::runtime_error(err);
66 66
 		}
67
-		
67
+
68 68
 		DKMap<Vertex, uint32_t> uniqueVertices;
69 69
 		DKLog("Save to Container");
70 70
 		for (const auto& shape : shapes)
@@ -85,7 +85,7 @@ public:
85 85
 					attrib.texcoords[2 * index.texcoord_index + 0],
86 86
 					1.0f - attrib.texcoords[2 * index.texcoord_index + 1]
87 87
 					};
88
-				}				
88
+				}
89 89
 
90 90
 				vertex.inColor = { 1.0f, 1.0f, 1.0f };
91 91
 
@@ -102,13 +102,13 @@ public:
102 102
 		}
103 103
 	}
104 104
 
105
-	uint32_t GetVerticesCount() const { 
105
+	uint32_t GetVerticesCount() const {
106 106
 		return static_cast<uint32_t>(vertices.Count()); };
107
-	uint32_t GetIndicesCount() const { 
107
+	uint32_t GetIndicesCount() const {
108 108
 		return static_cast<uint32_t>(indices.Count()); };
109
-	const Vertex* GetVerticesData() const { 
109
+	const Vertex* GetVerticesData() const {
110 110
 		return vertices; }
111
-	const uint32_t* GetIndicesData() const { 
111
+	const uint32_t* GetIndicesData() const {
112 112
 		return indices; }
113 113
 
114 114
     DKAabb aabb;
@@ -138,7 +138,7 @@ class MeshDemo : public SampleApp
138 138
 public:
139 139
 	void LoadMesh()
140 140
 	{
141
-		
141
+
142 142
 		DKLog("Loading Mesh");
143 143
         DKString path = resourcePool.ResourceFilePath("meshes/chalet.obj");
144 144
 		SampleMesh->LoadFromObjFile(DKStringU8(path));
@@ -171,7 +171,7 @@ public:
171 171
 
172 172
                 size_t bufferLength = bytesPerPixel * width * height;
173 173
                 DKObject<DKGpuBuffer> stagingBuffer = device->CreateBuffer(bufferLength, DKGpuBuffer::StorageModeShared, DKCpuCacheModeReadWrite);
174
-                
174
+
175 175
                 memcpy(stagingBuffer->Contents(), image->Contents(), bufferLength);
176 176
                 stagingBuffer->Flush();
177 177
 
@@ -211,7 +211,7 @@ public:
211 211
 		samplerDesc.addressModeV = DKSamplerDescriptor::AddressModeClampToEdge;
212 212
 		samplerDesc.addressModeW = DKSamplerDescriptor::AddressModeClampToEdge;
213 213
 		samplerDesc.maxAnisotropy = 16;
214
-		
214
+
215 215
 		DKObject<DKSamplerState> sampler = device->CreateSamplerState(samplerDesc);
216 216
 
217 217
         // create shaders
@@ -230,7 +230,7 @@ public:
230 230
 			DKLog("  --> VertexAttribute[%d]: \"%ls\" (location:%u)", i, (const wchar_t*)attr.name, attr.location);
231 231
 		}
232 232
 
233
-	
233
+
234 234
 		uint32_t vertexBufferSize = static_cast<uint32_t>(SampleMesh->GetVerticesCount()) * sizeof(SampleObjMesh::Vertex);
235 235
 		uint32_t indexBufferSize = SampleMesh->GetIndicesCount() * sizeof(uint32_t);
236 236
 
@@ -249,9 +249,9 @@ public:
249 249
         // setup color-attachment render-targets
250 250
 		pipelineDescriptor.colorAttachments.Resize(1);
251 251
 		pipelineDescriptor.colorAttachments.Value(0).pixelFormat = swapChain->ColorPixelFormat();
252
-        pipelineDescriptor.colorAttachments.Value(0).blendingEnabled = false;
253
-        pipelineDescriptor.colorAttachments.Value(0).sourceRGBBlendFactor = DKBlendFactor::SourceAlpha;
254
-        pipelineDescriptor.colorAttachments.Value(0).destinationRGBBlendFactor = DKBlendFactor::OneMinusSourceAlpha;
252
+        pipelineDescriptor.colorAttachments.Value(0).blendState.enabled = false;
253
+        pipelineDescriptor.colorAttachments.Value(0).blendState.sourceRGBBlendFactor = DKBlendFactor::SourceAlpha;
254
+        pipelineDescriptor.colorAttachments.Value(0).blendState.destinationRGBBlendFactor = DKBlendFactor::OneMinusSourceAlpha;
255 255
         // setup depth-stencil
256 256
 		pipelineDescriptor.depthStencilAttachmentPixelFormat = DKPixelFormat::D32Float;
257 257
         pipelineDescriptor.depthStencilDescriptor.depthWriteEnabled = true;
@@ -326,7 +326,7 @@ public:
326 326
                 //memcpy(uboBuffer->Contents(), &ubo, sizeof(ubo));
327 327
                 bindSet->SetBuffer(0, uboBuffer, 0, sizeof(UBO));
328 328
             }
329
-			         
329
+
330 330
             bindSet->SetTexture(1, texture);
331 331
             bindSet->SetSamplerState(1, sampler);
332 332
         }
@@ -336,7 +336,7 @@ public:
336 336
         DKCamera camera;
337 337
         DKVector3 cameraPosition = { 0, 5, 10 };
338 338
         DKVector3 cameraTartget = { 0, 0, 0 };
339
-		
339
+
340 340
         DKAffineTransform3 tm(DKLinearTransform3().Scale(5).Rotate(DKVector3(-1,0,0), DKGL_PI * 0.5));
341 341
 
342 342
         DKTimer timer;