@ -935,6 +935,7 @@ namespace olc
virtual olc : : rcode DestroyDevice ( ) = 0 ;
virtual olc : : rcode DestroyDevice ( ) = 0 ;
virtual void DisplayFrame ( ) = 0 ;
virtual void DisplayFrame ( ) = 0 ;
virtual void PrepareDrawing ( ) = 0 ;
virtual void PrepareDrawing ( ) = 0 ;
virtual void PrepareRender ( int width , int height ) = 0 ;
virtual void SetDecalMode ( const olc : : DecalMode & mode ) = 0 ;
virtual void SetDecalMode ( const olc : : DecalMode & mode ) = 0 ;
virtual void DrawLayerQuad ( const olc : : vf2d & offset , const olc : : vf2d & scale , const olc : : Pixel tint ) = 0 ;
virtual void DrawLayerQuad ( const olc : : vf2d & offset , const olc : : vf2d & scale , const olc : : Pixel tint ) = 0 ;
virtual void DrawDecal ( const olc : : DecalInstance & decal ) = 0 ;
virtual void DrawDecal ( const olc : : DecalInstance & decal ) = 0 ;
@ -3432,7 +3433,7 @@ namespace olc
void PixelGameEngine : : DrawStringDecal ( const olc : : vf2d & pos , std : : string_view sText , const Pixel col , const olc : : vf2d & scale , const float width , const bool disableDynamicScaling )
void PixelGameEngine : : DrawStringDecal ( const olc : : vf2d & pos , std : : string_view sText , const Pixel col , const olc : : vf2d & scale , const float width , const bool disableDynamicScaling )
{
{
struct DecalData {
struct DecalData {
Decal * decal ;
Decal * decal = nullptr ;
float expireTime = 0.0f ;
float expireTime = 0.0f ;
} ;
} ;
if ( sText . length ( ) = = 0 ) return ;
if ( sText . length ( ) = = 0 ) return ;
@ -3466,7 +3467,7 @@ namespace olc
void PixelGameEngine : : DrawStringPropDecal ( const olc : : vf2d & pos , std : : string_view sText , const Pixel col , const olc : : vf2d & scale , const float width , const bool disableDynamicScaling )
void PixelGameEngine : : DrawStringPropDecal ( const olc : : vf2d & pos , std : : string_view sText , const Pixel col , const olc : : vf2d & scale , const float width , const bool disableDynamicScaling )
{
{
struct DecalData {
struct DecalData {
Decal * decal ;
Decal * decal = nullptr ;
float expireTime = 0.0f ;
float expireTime = 0.0f ;
} ;
} ;
if ( sText . length ( ) = = 0 ) return ;
if ( sText . length ( ) = = 0 ) return ;
@ -3499,7 +3500,7 @@ namespace olc
void PixelGameEngine : : DrawShadowStringDecal ( const olc : : vf2d & pos , std : : string_view sText , const Pixel col , const Pixel shadowCol , const olc : : vf2d & scale , const float width , const float shadowSizeFactor , const bool disableDynamicScaling ) {
void PixelGameEngine : : DrawShadowStringDecal ( const olc : : vf2d & pos , std : : string_view sText , const Pixel col , const Pixel shadowCol , const olc : : vf2d & scale , const float width , const float shadowSizeFactor , const bool disableDynamicScaling ) {
struct DecalData {
struct DecalData {
Decal * decal ;
Decal * decal = nullptr ;
float expireTime = 0.0f ;
float expireTime = 0.0f ;
} ;
} ;
if ( sText . length ( ) = = 0 ) return ;
if ( sText . length ( ) = = 0 ) return ;
@ -3547,7 +3548,7 @@ namespace olc
void PixelGameEngine : : DrawStringDecal ( Font & font , const olc : : vf2d & pos , const std : : u32string & sText , const Pixel col , const olc : : vf2d & scale ) {
void PixelGameEngine : : DrawStringDecal ( Font & font , const olc : : vf2d & pos , const std : : u32string & sText , const Pixel col , const olc : : vf2d & scale ) {
struct DecalData {
struct DecalData {
Decal * decal ;
Decal * decal = nullptr ;
float expireTime = 0.0f ;
float expireTime = 0.0f ;
} ;
} ;
if ( sText . length ( ) = = 0 ) return ;
if ( sText . length ( ) = = 0 ) return ;
@ -3569,7 +3570,7 @@ namespace olc
void PixelGameEngine : : DrawShadowStringDecal ( Font & font , const olc : : vf2d & pos , const std : : u32string & sText , const Pixel col , const Pixel shadowCol , const olc : : vf2d & scale , const float shadowSizeFactor ) {
void PixelGameEngine : : DrawShadowStringDecal ( Font & font , const olc : : vf2d & pos , const std : : u32string & sText , const Pixel col , const Pixel shadowCol , const olc : : vf2d & scale , const float shadowSizeFactor ) {
struct DecalData {
struct DecalData {
Decal * decal ;
Decal * decal = nullptr ;
float expireTime = 0.0f ;
float expireTime = 0.0f ;
} ;
} ;
if ( sText . length ( ) = = 0 ) return ;
if ( sText . length ( ) = = 0 ) return ;
@ -3598,7 +3599,7 @@ namespace olc
void PixelGameEngine : : DrawDropShadowStringDecal ( Font & font , const olc : : vf2d & pos , const std : : u32string & sText , const Pixel col , const Pixel shadowCol , const olc : : vf2d & scale ) {
void PixelGameEngine : : DrawDropShadowStringDecal ( Font & font , const olc : : vf2d & pos , const std : : u32string & sText , const Pixel col , const Pixel shadowCol , const olc : : vf2d & scale ) {
struct DecalData {
struct DecalData {
Decal * decal ;
Decal * decal = nullptr ;
float expireTime = 0.0f ;
float expireTime = 0.0f ;
} ;
} ;
if ( sText . length ( ) = = 0 ) return ;
if ( sText . length ( ) = = 0 ) return ;
@ -3623,7 +3624,7 @@ namespace olc
void PixelGameEngine : : DrawShadowStringPropDecal ( const olc : : vf2d & pos , std : : string_view sText , const Pixel col , const Pixel shadowCol , const olc : : vf2d & scale , const float width , const float shadowSizeFactor , const bool disableDynamicScaling ) {
void PixelGameEngine : : DrawShadowStringPropDecal ( const olc : : vf2d & pos , std : : string_view sText , const Pixel col , const Pixel shadowCol , const olc : : vf2d & scale , const float width , const float shadowSizeFactor , const bool disableDynamicScaling ) {
struct DecalData {
struct DecalData {
Decal * decal ;
Decal * decal = nullptr ;
float expireTime = 0.0f ;
float expireTime = 0.0f ;
} ;
} ;
if ( sText . length ( ) = = 0 ) return ;
if ( sText . length ( ) = = 0 ) return ;
@ -4798,11 +4799,16 @@ namespace olc
layer - > bUpdate = false ;
layer - > bUpdate = false ;
}
}
renderer - > PrepareRender ( ScreenWidth ( ) , ScreenHeight ( ) ) ;
renderer - > DrawLayerQuad ( layer - > vOffset , layer - > vScale , layer - > tint ) ;
renderer - > DrawLayerQuad ( layer - > vOffset , layer - > vScale , layer - > tint ) ;
// Display Decals in order for this layer
// Display Decals in order for this layer
for ( auto & decal : layer - > vecDecalInstance )
for ( auto & decal : layer - > vecDecalInstance ) {
if ( decal . decal ! = nullptr ) {
renderer - > PrepareRender ( decal . decal - > sprite - > width , decal . decal - > sprite - > height ) ;
}
renderer - > DrawDecal ( decal ) ;
renderer - > DrawDecal ( decal ) ;
}
layer - > vecDecalInstance . clear ( ) ;
layer - > vecDecalInstance . clear ( ) ;
}
}
else
else
@ -4946,6 +4952,7 @@ namespace olc
virtual olc : : rcode DestroyDevice ( ) { return olc : : rcode : : OK ; }
virtual olc : : rcode DestroyDevice ( ) { return olc : : rcode : : OK ; }
virtual void DisplayFrame ( ) { }
virtual void DisplayFrame ( ) { }
virtual void PrepareDrawing ( ) { }
virtual void PrepareDrawing ( ) { }
virtual void PrepareRender ( int width , int height ) { } ;
virtual void SetDecalMode ( const olc : : DecalMode & mode ) { }
virtual void SetDecalMode ( const olc : : DecalMode & mode ) { }
virtual void DrawLayerQuad ( const olc : : vf2d & offset , const olc : : vf2d & scale , const olc : : Pixel tint ) { }
virtual void DrawLayerQuad ( const olc : : vf2d & offset , const olc : : vf2d & scale , const olc : : Pixel tint ) { }
virtual void DrawDecal ( const olc : : DecalInstance & decal ) { }
virtual void DrawDecal ( const olc : : DecalInstance & decal ) { }
@ -5125,7 +5132,7 @@ namespace olc
glHint ( GL_PERSPECTIVE_CORRECTION_HINT , GL_NICEST ) ;
glHint ( GL_PERSPECTIVE_CORRECTION_HINT , GL_NICEST ) ;
# endif
# endif
}
}
void PrepareRender ( int width , int height ) override { } ;
olc : : rcode CreateDevice ( std : : vector < void * > params , bool bFullScreen , bool bVSYNC ) override
olc : : rcode CreateDevice ( std : : vector < void * > params , bool bFullScreen , bool bVSYNC ) override
{
{
# if defined(OLC_PLATFORM_WINAPI)
# if defined(OLC_PLATFORM_WINAPI)
@ -5754,7 +5761,7 @@ namespace olc
" uniform sampler2D sprTex; \n "
" uniform sampler2D sprTex; \n "
" void main(){ \n "
" void main(){ \n "
" if(mosaic<=1){pixel = texture(sprTex,oTex) * oCol;return;} \n "
" if(mosaic<=1){pixel = texture(sprTex,oTex) * oCol;return;} \n "
" vec2 texelSize = 1.0 / textureSize(sprTex,0) ; \n "
" vec2 texelSize = 1.0 / size ; \n "
" vec2 pos = oTex / texelSize; \n " " vec2 outputPos = vec2(floor(pos.x/float(mosaic))*float(mosaic),floor(pos.y/float(mosaic))*float(mosaic)); \n "
" vec2 pos = oTex / texelSize; \n " " vec2 outputPos = vec2(floor(pos.x/float(mosaic))*float(mosaic),floor(pos.y/float(mosaic))*float(mosaic)); \n "
" pixel = texture(sprTex, outputPos*texelSize) * oCol; \n "
" pixel = texture(sprTex, outputPos*texelSize) * oCol; \n "
" } " ;
" } " ;
@ -5876,6 +5883,11 @@ namespace olc
# endif
# endif
}
}
void PrepareRender ( int width , int height ) override {
GLint sizeUniformLoc = locGetUniformLocation ( m_nQuadShader , " size " ) ;
locUniform2f ( sizeUniformLoc , width , height ) ;
}
void SetDecalMode ( const olc : : DecalMode & mode ) override
void SetDecalMode ( const olc : : DecalMode & mode ) override
{
{
if ( mode ! = nDecalMode )
if ( mode ! = nDecalMode )