Virtual Nomad/Raven,
Thank you. I finally got it working and it looks nice on Windows and Android, but the iOS is not pretty (probably an Apple thing that I have no idea how to make work properly yet). I had to finally write some short VS and PS code that took care of the performance issues. For those interested I included the AppGameKit code and the shader codes. The color in this instance used to make parts of the covering sprite become transparent must be color (RGB) 12, 12, 12 or less. I used 0, 0, 0 as the color to render onto the image.
AGK:
// Project: revealwshaderv1
// Created: 2022-05-23
#constant KEY_ESCAPE 27
#constant SCREEN_WIDTH 1024
#constant SCREEN_HEIGHT 768
SetErrorMode(2)
// set window properties
SetWindowTitle( "revealwshaderv1" )
SetWindowSize(SCREEN_WIDTH, SCREEN_HEIGHT, 0)
SetWindowAllowResize(0)
SetOrientationAllowed(0, 0, 1, 1)
SetVirtualResolution(SCREEN_WIDTH, SCREEN_HEIGHT)
SetSyncRate(0, 0)
SetScissor(0,0,0,0)
UseNewDefaultFonts(1)
//SetRawMouseVisible(0) //hide mouse cursor
Global dw as Integer
Global dh as Integer
Global TSprite as Integer
Global CircleImageID as Integer
Global x2 as Float
Global y2 as Float
Global rechide as Integer //sprite number for hidden rectangle
Global imgRender as Integer //gray area image
Global imgRender1 as Integer //gray area image
Global rechImageID as Integer //image number for hidden sprite
Global shaderid as Integer //shader number
Global tops as Integer //top of screen
Global lefts as Integer //left side of screen
Global rights as Integer //right bounds
Global bottoms as integer //bottom bounds
dw = GetDeviceWidth()
dh = GetDeviceHeight()
tops = GetScreenBoundsTop()
lefts = GetScreenBoundsLeft()
rights = GetScreenBoundsRight()
bottoms = GetScreenBoundsBottom()
imgRender1 = CreateRenderImage(SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0)
SetRenderToImage(imgRender1, 0)
ClearScreen()
DrawBox(lefts, tops, 512 * (dw/512), 384 * (dh/384), MakeColor(20,20,20), MakeColor(20,20,20), MakeColor(20,20,20), MakeColor(20,20,20), 1) //dark gray image for covering sprite
SetRenderToScreen()
ClearScreen()
//pointer
DrawEllipse(12, 12, 12, 12, MakeColor(255, 0, 0), MakeColor(255, 0, 0), 1)
CircleImageID=GetImage(0,0,48,48)
TSpriteID=CreateSprite(CircleImageID) //pointer sprite
SetSpritePosition(TSpriteID, 700, 700)
SetSpriteDepth(TSpriteID, 4)
SetSpriteOffSet(TSpriteID, 12, 12)
ClearScreen()
//hidden image
DrawBox(0, 0, 512, 384, MakeColor(10,10,255), MakeColor(10,10,255), MakeColor(10,10,255), MakeColor(10,10,255), 1) //blue image for covered sprite
rechImageID=GetImage(0, 0, 512, 384)
ClearScreen()
rechide = CreateSprite(rechImageID) //create covered blue sprite
SetSpritePosition(rechide, 100, 100)
SetSpriteSize(rechide, 512, 384)
SetSpriteDepth(rechide, 9)
// overlay image that will be rubbed away with pointer
shaderid = LoadShader("alphaoff.vs", "alphaoff.ps")
sprRender = CreateSprite(imgRender1)
SetSpritePosition(sprRender, 100, 100)
SetSpriteSize(sprRender, 512, 384)
SetSpriteTransparency(sprRender, 1)
SetSpriteDepth(sprRender, 8)
SetSpriteShader(sprRender, shaderid)
do
x2 = GetPointerX()
y2 = GetPointerY()
If (GetPointerState() = 1)
SetRenderToImage(imgRender1, 0)
//set ellipse to same color as transparency color and convert x2# and y2# coordinates for ellipse to render image coordinates of tops ,lefts to 1023,767 (screen resolution) using hidden image's left and top positions--could use scratch off image position as well
DrawEllipse((x2 - GetSpriteX(rechide)) * ((rights + ABS(lefts))/GetSpriteWidth(rechide)) + Lefts, (y2 - GetSpriteY(rechide)) * ((bottoms + ABS(tops))/GetSpriteHeight(rechide)), 24, 24, MakeColor(0, 0, 0), MakeColor(0, 0, 0), 1)
//SetShaderConstantByName(shaderid,"AlphaOff",1.0, 0.0, 0.0, 0.0)
EndIf
SetRenderToScreen()
ClearScreen()
SetSpritePositionByOffset(TSpriteID, x2, y2)
If (GetRawKeyState(KEY_ESCAPE) = 1)
End
EndIf
Print( ScreenFPS() )
Sync()
loop
VS:
attribute highp vec4 position;
attribute mediump vec4 color;
attribute mediump vec2 uv;
varying mediump vec2 uvVarying;
varying mediump vec4 colorVarying;
uniform highp mat4 agk_Ortho;
void main()
{
gl_Position = agk_Ortho * position;
uvVarying = uv;
colorVarying = color;
}
PS:
uniform sampler2D texture0;
varying mediump vec2 uvVarying;
varying mediump vec4 colorVarying;
uniform lowp vec4 AlphaOff;
void main()
{
vec4 tcol = texture2D(texture0, uvVarying);
if (tcol.r <= 0.05 && tcol.g <= 0.05 && tcol.b <= 0.05) //alpha any black drawing that is around RGB 12, 12, 12 or less
{
gl_FragColor = AlphaOff;
}
else
{
gl_FragColor = tcol;
}
}