@@ -38,9 +38,10 @@ enum class ExampleMode
38
38
CASE_3, // CURVES AND LINES
39
39
CASE_4, // STIPPLE PATTERN
40
40
CASE_5, // Advanced Styling
41
+ CASE_6, // Custom Clip Projections
41
42
};
42
43
43
- constexpr ExampleMode mode = ExampleMode::CASE_2 ;
44
+ constexpr ExampleMode mode = ExampleMode::CASE_6 ;
44
45
45
46
class Camera2D
46
47
{
@@ -1091,15 +1092,13 @@ class ComputerAidedDesign final : public examples::SimpleWindowedApplication, pu
1091
1092
if (!inBetweenSubmit)
1092
1093
cb->endDebugMarker ();
1093
1094
1094
- cb->end ();
1095
-
1096
1095
if (inBetweenSubmit)
1097
1096
{
1098
1097
intendedSubmitInfo.overflowSubmit ();
1099
- drawBuffer.reset ();
1100
1098
}
1101
1099
else
1102
1100
{
1101
+ cb->end ();
1103
1102
IQueue::SSubmitInfo submitInfo = static_cast <IQueue::SSubmitInfo>(intendedSubmitInfo);
1104
1103
if (getGraphicsQueue ()->submit ({ &submitInfo, 1u }) == IQueue::RESULT::SUCCESS)
1105
1104
{
@@ -1650,16 +1649,6 @@ class ComputerAidedDesign final : public examples::SimpleWindowedApplication, pu
1650
1649
}
1651
1650
else if (mode == ExampleMode::CASE_4)
1652
1651
{
1653
- ClipProjectionData newClipProj = {};
1654
- newClipProj.projectionToNDC = m_Camera.constructViewProjection ();
1655
- newClipProj.minClipNDC = float32_t2 (0.0 , -1.0 );
1656
- newClipProj.maxClipNDC = float32_t2 (+1.0 , +1.0 );
1657
- drawBuffer.pushClipProjectionData (newClipProj);
1658
- drawBuffer.pushClipProjectionData (newClipProj);
1659
- newClipProj.minClipNDC = float32_t2 (-1.0 , -1.0 );
1660
- newClipProj.maxClipNDC = float32_t2 (+1.0 , +0.5 );
1661
- drawBuffer.pushClipProjectionData (newClipProj);
1662
-
1663
1652
constexpr uint32_t CURVE_CNT = 16u ;
1664
1653
constexpr uint32_t SPECIAL_CASE_CNT = 6u ;
1665
1654
@@ -1806,8 +1795,6 @@ class ComputerAidedDesign final : public examples::SimpleWindowedApplication, pu
1806
1795
1807
1796
for (uint32_t i = 0u ; i < CURVE_CNT; i++)
1808
1797
drawBuffer.drawPolyline (polylines[i], lineStyleInfos[i], intendedNextSubmit);
1809
-
1810
- drawBuffer.popClipProjectionData ();
1811
1798
}
1812
1799
else if (mode == ExampleMode::CASE_5)
1813
1800
{
@@ -2367,6 +2354,103 @@ class ComputerAidedDesign final : public examples::SimpleWindowedApplication, pu
2367
2354
2368
2355
#endif
2369
2356
2357
+ }
2358
+ else if (mode == ExampleMode::CASE_6)
2359
+ {
2360
+ // left half of screen should be red and right half should be green
2361
+ const auto & cameraProj = m_Camera.constructViewProjection ();
2362
+ ClipProjectionData showLeft = {};
2363
+ showLeft.projectionToNDC = cameraProj;
2364
+ showLeft.minClipNDC = float32_t2 (-1.0 , -1.0 );
2365
+ showLeft.maxClipNDC = float32_t2 (0.0 , +1.0 );
2366
+ ClipProjectionData showRight = {};
2367
+ showRight.projectionToNDC = cameraProj;
2368
+ showRight.minClipNDC = float32_t2 (0.0 , -1.0 );
2369
+ showRight.maxClipNDC = float32_t2 (+1.0 , +1.0 );
2370
+
2371
+ LineStyleInfo leftLineStyle = {};
2372
+ leftLineStyle.screenSpaceLineWidth = 3 .0f ;
2373
+ leftLineStyle.worldSpaceLineWidth = 0 .0f ;
2374
+ leftLineStyle.color = float32_t4 (1 .0f , 0 .1f , 0 .1f , 0 .9f );
2375
+ leftLineStyle.isRoadStyleFlag = false ;
2376
+ LineStyleInfo rightLineStyle = {};
2377
+ rightLineStyle.screenSpaceLineWidth = 6 .0f ;
2378
+ rightLineStyle.worldSpaceLineWidth = 0 .0f ;
2379
+ rightLineStyle.color = float32_t4 (0 .1f , 1 .0f , 0 .1f , 0 .9f );
2380
+ rightLineStyle.isRoadStyleFlag = false ;
2381
+
2382
+ CPolyline polyline3;
2383
+ {
2384
+ std::vector<float64_t2> linePoints;
2385
+ linePoints.push_back ({ -20.0 , 20.0 });
2386
+ linePoints.push_back ({ 20.0 , 70.0 });
2387
+ linePoints.push_back ({ 20.0 , -40.0 });
2388
+ polyline3.addLinePoints (linePoints);
2389
+ }
2390
+ CPolyline polyline1;
2391
+ {
2392
+ std::vector<float64_t2> linePoints;
2393
+ linePoints.push_back ({ -20.0 , 0.0 });
2394
+ linePoints.push_back ({ -20.0 , 50.0 });
2395
+ linePoints.push_back ({ 20.0 , 0.0 });
2396
+ linePoints.push_back ({ 20.0 , 50.0 });
2397
+ polyline1.addLinePoints (linePoints);
2398
+ }
2399
+ CPolyline polyline2;
2400
+ {
2401
+
2402
+ std::vector<shapes::QuadraticBezier<double >> quadBeziers;
2403
+ curves::EllipticalArcInfo myCurve;
2404
+ {
2405
+ myCurve.majorAxis = { 20.0 , 0.0 };
2406
+ myCurve.center = { 0.0 , -25.0 };
2407
+ myCurve.angleBounds = {
2408
+ nbl::core::PI<double >() * 0.0 ,
2409
+ nbl::core::PI<double >() * 2.0
2410
+ };
2411
+ myCurve.eccentricity = 1.0 ;
2412
+ }
2413
+
2414
+ curves::Subdivision::AddBezierFunc addToBezier = [&](shapes::QuadraticBezier<double >&& info) -> void
2415
+ {
2416
+ quadBeziers.push_back (info);
2417
+ };
2418
+
2419
+ curves::Subdivision::adaptive (myCurve, 1e-3 , addToBezier, 10u );
2420
+ polyline2.addQuadBeziers (quadBeziers);
2421
+ }
2422
+
2423
+ // we do redundant and nested push/pops to test
2424
+ drawBuffer.pushClipProjectionData (showLeft);
2425
+ {
2426
+ drawBuffer.drawPolyline (polyline1, leftLineStyle, intendedNextSubmit);
2427
+
2428
+ drawBuffer.pushClipProjectionData (showRight);
2429
+ {
2430
+ drawBuffer.drawPolyline (polyline1, rightLineStyle, intendedNextSubmit);
2431
+ drawBuffer.drawPolyline (polyline2, rightLineStyle, intendedNextSubmit);
2432
+ }
2433
+ drawBuffer.popClipProjectionData ();
2434
+
2435
+ drawBuffer.drawPolyline (polyline2, leftLineStyle, intendedNextSubmit);
2436
+
2437
+ drawBuffer.pushClipProjectionData (showRight);
2438
+ {
2439
+ drawBuffer.drawPolyline (polyline3, rightLineStyle, intendedNextSubmit);
2440
+ drawBuffer.drawPolyline (polyline2, rightLineStyle, intendedNextSubmit);
2441
+
2442
+ drawBuffer.pushClipProjectionData (showLeft);
2443
+ {
2444
+ drawBuffer.drawPolyline (polyline1, leftLineStyle, intendedNextSubmit);
2445
+ }
2446
+ drawBuffer.popClipProjectionData ();
2447
+ }
2448
+ drawBuffer.popClipProjectionData ();
2449
+
2450
+ drawBuffer.drawPolyline (polyline2, leftLineStyle, intendedNextSubmit);
2451
+ }
2452
+ drawBuffer.popClipProjectionData ();
2453
+
2370
2454
}
2371
2455
2372
2456
drawBuffer.finalizeAllCopiesToGPU (intendedNextSubmit);
0 commit comments