Hi zpaolo11x,
I'm including a screen shot of what the screen looks like in addition to the code that doesn't work:
local snap = snapSurface.add_artwork( "snap", 0, 0 ); // This gets resized depending on the dimensions of the actual snap. Function below.
snap.set_pos( snapSurface.width / 2, snapSurface.height / 2 );
local snapShader = fe.add_shader( Shader.Fragment, "pseudo_scanlines.glsl" );
snapShader.set_texture_param( "source", snap );
snapShader.set_param( "rez", snap.width, snap.height );
snapShader.set_param( "lineWeight", snap.width, snap.height );
snap.shader = snapShader;
What happens is I get a mostly black image where the snap used to be. Maybe it's all black. I can't tell sometimes. If I modify the "rez" param like so:
snapShader.set_param( "rez", fe.layout.width, fe.layout.height );
I get a scaled up, upside-down snap! I don't know if a vertex shader would solve my problems or just introduce new ones. The snap size/position changes based on its actual dimensions:
function updateSnapSize (ttype, var, ttime) {
// Get proper aspect ratio:
local _rez = null;
local _r = null;
if ( snap.texture_width == 0 || snap.texture_height == 0 ) {
_rez = { "w": snap.width, "h": snap.height }
}
else {
_rez = {"w": snap.texture_width, "h": snap.texture_height }
}
_r = _rez.w >= _rez.h ? _rez.h.tofloat() / _rez.w.tofloat() : _rez.w.tofloat() / _rez.h.tofloat();
switch ( ttype ) {
case Transition.StartLayout:
case Transition.ToNewList:
case Transition.ToNewSelection:
case Transition.EndNavigation:
// Resize snap:
if ( _rez.w >= _rez.h ) {
// Landscape (or square):
snap.width = snapVars.max;
snap.height = snapVars.max * _r;
}
else {
// Portrait:
snap.width = snapVars.max * _r;
snap.height = snapVars.max;
}
// Resize snapFrame:
snapFrame.width = snap.width + snapVars.frameWeight;
snapFrame.height = snap.height + snapVars.frameWeight;
// Update origins:
snapFrame.origin_x = snapFrame.width / 2;
snapFrame.origin_y = snapFrame.height / 2;
snap.origin_x = snap.width / 2;
snap.origin_y = snap.height / 2;
// Update drop shadow:
// NOTE: This works! It's probably voodoo, so don't look too closely!
snapDS.surface.origin_x = snapFrame.width / 2;
snapDS.surface.origin_y = snapFrame.height / 2;
snapDS.surface.set_pos(
snapVars.dropShadowOffset.x + (snapOrigin.x - snapVars.dropShadowSize),
snapVars.dropShadowOffset.y + (snapOrigin.y - snapVars.dropShadowSize),
snapFrame.width + (snapVars.dropShadowSize * 2),
snapFrame.height + (snapVars.dropShadowSize * 2)
);
// Reposition gameCount:
gameCount.set_pos( snapOrigin.x - (gameCount.width / 2), snapOrigin.y + (snapFrame.height / 2.0).tofloat() + 16);
// Adjust zorder:
snap.zorder = snapFrame.zorder + 1;
snapSurface.zorder = snapDS.surface.zorder + 1;
gameCount.zorder = snapSurface.zorder + 1;
break;
}
}
That size/position changing stuff may or may not mess with the shader. Not sure.
If you or anyone else is able to deduce a solution, I'm all ears! Thanks, as always, for taking a look!
Edit: Holy smokes, that's a large screen shot. Apologies! (Edit 2: Resized attachment)