8
8
#include " GLResourceMan.h"
9
9
#include " BigTexture.h"
10
10
11
+ #include " Draw.h"
11
12
#include " tracy/Tracy.hpp"
12
13
#include " tracy/TracyOpenGL.hpp"
13
14
@@ -418,7 +419,7 @@ void SceneLayerImpl<TRACK_DRAWINGS, STATIC_TEXTURE>::UpdateTargetRegion(const Bo
418
419
std::vector<Box> updateRegions{};
419
420
m_MainTexture->m_Bitmap = m_MainBitmap;
420
421
421
- if (m_MainBitmap-> w < targetBox.m_Width && m_MainBitmap-> h < targetBox.m_Height ) {
422
+ if (m_ScaledDimensions. m_X < targetBox.m_Width && m_ScaledDimensions. m_Y < targetBox.m_Height ) {
422
423
// Bitmap will be in frame entirely, upload all.
423
424
updateRegions.emplace_back (
424
425
Vector (),
@@ -429,32 +430,32 @@ void SceneLayerImpl<TRACK_DRAWINGS, STATIC_TEXTURE>::UpdateTargetRegion(const Bo
429
430
// Upload wrapped region
430
431
431
432
Box cornerWrapEither (
432
- m_Offset,
433
- std::min (m_MainBitmap-> w - m_Offset.m_X ,targetBox.m_Width ),
434
- std::min (m_MainBitmap-> h - m_Offset.m_Y , targetBox.m_Height )
433
+ m_Offset / m_ScaleFactor ,
434
+ std::min ((m_ScaledDimensions. m_X - m_Offset.m_X ) / m_ScaleFactor. m_X ,targetBox.m_Width / m_ScaleFactor. m_X ),
435
+ std::min ((m_ScaledDimensions. m_Y - m_Offset.m_Y ) / m_ScaleFactor. m_Y , targetBox.m_Height / m_ScaleFactor. m_Y )
435
436
);
436
437
updateRegions.push_back (cornerWrapEither);
437
438
438
439
if (m_WrapX && cornerWrapEither.m_Width < targetBox.m_Width ) {
439
440
updateRegions.emplace_back (
440
- Vector (0 , m_Offset.m_Y ),
441
- targetBox.m_Width + m_Offset.m_X - m_MainBitmap-> w ,
442
- std::min (m_MainBitmap-> h - m_Offset.m_Y , targetBox.m_Height )
441
+ Vector (0 , m_Offset.m_Y ) / m_ScaleFactor ,
442
+ ( targetBox.m_Width + m_Offset.m_X - m_ScaledDimensions. m_X ) / m_ScaleFactor. m_X ,
443
+ std::min (m_ScaledDimensions. m_Y - m_Offset.m_Y , targetBox.m_Height ) / m_ScaleFactor. m_Y
443
444
);
444
445
}
445
446
if (m_WrapY && cornerWrapEither.m_Height < targetBox.m_Width ) {
446
447
updateRegions.emplace_back (
447
- Vector (m_Offset.m_X , 0 ),
448
- std::min (m_MainBitmap-> w - m_Offset.m_X , targetBox.m_Width ),
449
- targetBox.m_Height + m_Offset.m_Y - m_MainBitmap-> h
448
+ Vector (m_Offset.m_X , 0 ) / m_ScaleFactor ,
449
+ std::min (m_ScaledDimensions. m_X - m_Offset.m_X , targetBox.m_Width ) / m_ScaleFactor. m_X ,
450
+ ( targetBox.m_Height + m_Offset.m_Y - m_ScaledDimensions. m_Y ) / m_ScaleFactor. m_Y
450
451
);
451
452
}
452
453
453
454
if (m_WrapX && m_WrapY && cornerWrapEither.m_Height < targetBox.m_Height && cornerWrapEither.m_Width < targetBox.m_Width ) {
454
455
updateRegions.emplace_back (
455
456
Vector (),
456
- targetBox.m_Width + m_Offset.m_X - m_MainBitmap-> w ,
457
- targetBox.m_Height + m_Offset.m_Y - m_MainBitmap-> h
457
+ ( targetBox.m_Width + m_Offset.m_X - m_ScaledDimensions. m_X ) / m_ScaleFactor. m_X ,
458
+ ( targetBox.m_Height + m_Offset.m_Y - m_ScaledDimensions. m_Y ) / m_ScaleFactor. m_Y
458
459
);
459
460
}
460
461
}
@@ -511,34 +512,28 @@ void SceneLayerImpl<TRACK_DRAWINGS, STATIC_TEXTURE>::DrawTiled(const Box& target
511
512
int areaToCoverX = m_Offset.GetFloorIntX () + targetBox.GetCorner ().GetFloorIntX () + std::min (targetDimensions.GetWidth (), targetBox.GetWidth ());
512
513
int areaToCoverY = m_Offset.GetFloorIntY () + targetBox.GetCorner ().GetFloorIntY () + std::min (targetDimensions.GetHeight (), targetBox.GetHeight ());
513
514
515
+ if (!m_DrawMasked) {
516
+ rlDrawRenderBatchActive ();
517
+ int maskedUniformLocation = rlGetLocationUniform (rlGetShaderCurrent (), " drawMasked" );
518
+ rlEnableShader (rlGetShaderCurrent ());
519
+ glUniform1i (maskedUniformLocation, 0 );
520
+ }
521
+
514
522
for (int tiledOffsetX = 0 ; tiledOffsetX < areaToCoverX;) {
515
523
float destX = targetBox.GetCorner ().GetFloorIntX () + tiledOffsetX - m_Offset.GetFloorIntX ();
516
524
517
525
for (int tiledOffsetY = 0 ; tiledOffsetY < areaToCoverY;) {
518
526
float destY = targetBox.GetCorner ().GetFloorIntY () + tiledOffsetY - m_Offset.GetFloorIntY ();
519
-
520
- if (!drawScaled) {
521
- if constexpr (STATIC_TEXTURE) {
522
- DrawTexture (g_GLResourceMan.GetStaticTextureFromBitmap (m_MainBitmap), destX, destY, {255 , 255 , 255 , 255 });
523
- } else {
524
- m_MainTexture->Draw (
525
- {0 .f , 0 .f , static_cast <float >(m_MainBitmap->w ), static_cast <float >(m_MainBitmap->h )},
526
- {destX, destY, static_cast <float >(m_MainBitmap->w ), static_cast <float >(m_MainBitmap->h )}
527
- );
528
- }
527
+ if constexpr (STATIC_TEXTURE) {
528
+ DrawTexturePro (
529
+ g_GLResourceMan.GetStaticTextureFromBitmap (m_MainBitmap),
530
+ {0 .0f , 0 .0f , static_cast <float >(m_MainBitmap->w ), static_cast <float >(m_MainBitmap->h )},
531
+ {destX, destY, bitmapWidth, bitmapHeight},
532
+ {0 .0f , 0 .0f }, 0 .0f , {255 , 255 , 255 , 255 });
529
533
} else {
530
- if constexpr (STATIC_TEXTURE) {
531
- DrawTexturePro (
532
- g_GLResourceMan.GetStaticTextureFromBitmap (m_MainBitmap),
533
- {0 .0f , 0 .0f , static_cast <float >(m_MainBitmap->w ), static_cast <float >(m_MainBitmap->h )},
534
- {destX, destY, bitmapWidth, bitmapHeight},
535
- {0 .0f , 0 .0f }, 0 .0f , {255 , 255 , 255 , 255 });
536
- } else {
537
- m_MainTexture->Draw (
538
- {0 .0f , 0 .0f , static_cast <float >(m_MainBitmap->w ), static_cast <float >(m_MainBitmap->h )},
539
- {destX, destY, bitmapWidth, bitmapHeight}
540
- );
541
- }
534
+ m_MainTexture->Draw (
535
+ {0 .0f , 0 .0f , static_cast <float >(m_MainBitmap->w ), static_cast <float >(m_MainBitmap->h )},
536
+ {destX, destY, bitmapWidth, bitmapHeight});
542
537
}
543
538
if (!m_WrapY) {
544
539
break ;
@@ -550,6 +545,13 @@ void SceneLayerImpl<TRACK_DRAWINGS, STATIC_TEXTURE>::DrawTiled(const Box& target
550
545
}
551
546
tiledOffsetX += bitmapWidth;
552
547
}
548
+
549
+ if (!m_DrawMasked) {
550
+ rlDrawRenderBatchActive ();
551
+ int drawMaskedUniform = rlGetLocationUniform (rlGetShaderCurrent (), " drawMasked" );
552
+ rlEnableShader (rlGetShaderCurrent ());
553
+ glUniform1i (drawMaskedUniform, 1 );
554
+ }
553
555
}
554
556
555
557
template <bool TRACK_DRAWINGS, bool STATIC_TEXTURE>
0 commit comments